Job class defined in same file as __main__ AttributeError

88 views
Skip to first unread message

Ryan Nowakowski

unread,
Apr 19, 2012, 1:46:22 PM4/19/12
to disc...@googlegroups.com
I'm having an issue defining a Job class in the same file as my main script.

from disco.job import Job
class FirstJob(Job):
input = ["file://testwords.txt"]
@staticmethod
def map(line, params):
yield int(line) + 1, ""
if __name__ == "__main__":
last = FirstJob().run().wait()

In same folder I created file "testwords.txt" and run mychain.py, I got:
disco.error.JobError: Job FirstJob@529:f4221:5146f failed: Status dead
in disco interface:
AttributeError: 'module' object has no attribute 'FirstJob'


Is it a python path issue?

- Ryan

Jens Rantil

unread,
Apr 20, 2012, 1:42:25 AM4/20/12
to disc...@googlegroups.com
Hi Ryan,

Trying putting your Job class in a separate Python module. I remember
I was having issues with this a while ago.

Jens

Sent from my iPhone 5

> --
> You received this message because you are subscribed to the Google Groups "Disco-development" group.
> To post to this group, send email to disc...@googlegroups.com.
> To unsubscribe from this group, send email to disco-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/disco-dev?hl=en.
>

Ryan Nowakowski

unread,
May 16, 2012, 12:52:11 PM5/16/12
to disc...@googlegroups.com
FYI, this works:

# mymodule.py
from disco.job import Job
class FirstJob(Job):
input = ["file://testwords.txt"]
@staticmethod
def map(line, params):
yield int(line) + 1, ""

if __name__ == "__main__":
from mymodule import FirstJob
last = FirstJob().run().wait()

guit...@gmail.com

unread,
Mar 26, 2014, 5:43:57 PM3/26/14
to disc...@googlegroups.com
Hi. It indeed solve the problem. As I'm curious about Disco's internals, can you explain why it works?

Stefano

unread,
Mar 28, 2014, 3:29:51 AM3/28/14
to disc...@googlegroups.com
alternative: you can have everything in the same file but you should still import your python class in the main.
To unsubscribe from this group and stop receiving emails from it, send an email to disco-dev+...@googlegroups.com.

To post to this group, send email to disc...@googlegroups.com.
Visit this group at http://groups.google.com/group/disco-dev.
For more options, visit https://groups.google.com/d/optout.


--

Gr,

Stefano
Reply all
Reply to author
Forward
0 new messages