initialization of a StagedTaskCollection

5 views
Skip to first unread message

Riccardo Murri

unread,
Nov 22, 2016, 3:26:49 PM11/22/16
to gc3...@googlegroups.com
Hi all,

With Jody's consent, I am including the list in this reply because I
think the question asked might be of general interest to all those doing
GC3Pie programming.

Jody asked this question in a private email:

> I implemented a derived classlike this:
> -----
> class WarholizePipeApp(StagedTaskCollection):
> def __init__(self, N, img, body, finaldir):
> self.N = N
> self.img=img
> self.body=body
> self.finaldir = finaldir
> self.outdir="warhol.tmp.d"
> #-- end def
> ### (rest of code omitted as not relevant to solution, RM) ###
> ----
>
> When i run this i get the message:
> ----
> gc3.gc3utils: CRITICAL: AttributeError: 'WarholizePipeApp' object has no attribute 'output_dir'
> ----

This is an instance of GC3Pie issue #583 [1], which should be fixed in
the latest commits on the "master" branch. Can you please upgrade your
GC3Pie installation and try again?

[1]: https://github.com/uzh/gc3pie/issues/583


> If i add the line 'self.output_dir=self.finaldir' to __init__, i get the message
> ----
> gc3.gc3utils: CRITICAL: AttributeError: 'WarholizePipeApp' object has no attribute '_changed'
> ----
>
> Can you tell me how i have to work with the StagedCollection?

This is because the `WarholizePipeApp.__init__()` method does not call
the superclass constructor `StagedTaskCollection.__init__()`. In other
words, a correct initialization sequence would be::

class WarholizePipeApp(StagedTaskCollection):
def __init__(self, N, img, body, finaldir):
# init superclass
StagedTaskCollection.__init__(self)
# add "local" attributes
self.N = N
self.img=img
self.body=body
self.finaldir = finaldir
self.outdir="warhol.tmp.d"
#-- end def

If you took the example code from the "programmers' tutorial" slides,
I have now fixed those too (*blush*).

Hope this helps!

Ciao,
R

--
Riccardo Murri
http://www.s3it.uzh.ch/about/team/#Riccardo.Murri

S3IT: Services and Support for Science IT
University of Zurich
Winterthurerstrasse 190, CH-8057 Zürich (Switzerland)

Tel: +41 44 635 4208
Fax: +41 44 635 6888
Reply all
Reply to author
Forward
0 new messages