hello world

101 views
Skip to first unread message

Marchello Lippi

unread,
Aug 6, 2020, 6:47:14 PM8/6/20
to luigi...@googlegroups.com
Hi all,

I'm new to Python, finishing basic course on codecademy.

Trying to follow below hello world example:
https://github.com/spotify/luigi/blob/master/examples/hello_world.py

Getting error:

$ luigi --module examples.hello_world examples.HelloWorldTask
--local-scheduler
Traceback (most recent call last):
File "/home/user1/.local/bin/luigi", line 7, in <module>
from luigi.cmdline import luigi_run
File
"/home/user1/.local/lib/python2.7/site-packages/luigi/__init__.py", line
23, in <module>
from luigi import task
File "/home/user1/.local/lib/python2.7/site-packages/luigi/task.py",
line 145
class Task(metaclass=Register):
^
SyntaxError: invalid syntax


How do I fix that? Please advise.

Best,
Marchello

Marchello Lippi

unread,
Aug 6, 2020, 7:27:44 PM8/6/20
to luigi...@googlegroups.com
Removed previous pip installation of luigi and installed it again using
pip3.
Ran hello world example command again.
Now the error message is different:

$ luigi --module examples.hello_world examples.HelloWorldTask
--local-scheduler
Traceback (most recent call last):
File "/home/ymarkiv/.local/bin/luigi", line 11, in <module>
sys.exit(luigi_run())
File
"/home/ymarkiv/.local/lib/python3.6/site-packages/luigi/cmdline.py",
line 9, in luigi_run
run_with_retcodes(argv)
File
"/home/ymarkiv/.local/lib/python3.6/site-packages/luigi/retcodes.py",
line 70, in run_with_retcodes
with luigi.cmdline_parser.CmdlineParser.global_instance(argv):
File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File
"/home/ymarkiv/.local/lib/python3.6/site-packages/luigi/cmdline_parser.py",
line 52, in global_instance
new_value = CmdlineParser(cmdline_args)
File
"/home/ymarkiv/.local/lib/python3.6/site-packages/luigi/cmdline_parser.py",
line 64, in __init__
self._attempt_load_module(known_args)
File
"/home/ymarkiv/.local/lib/python3.6/site-packages/luigi/cmdline_parser.py",
line 142, in _attempt_load_module
__import__(module)
ModuleNotFoundError: No module named 'examples'

How do I fix that? Please advise.


Marchello Lippi

unread,
Aug 6, 2020, 7:42:32 PM8/6/20
to luigi...@googlegroups.com
Ok, it seems I was able to run hello world in the python3 environment,
though there were some errors anyway, but seems finished successfully.
It would be great if someone could comment how do I get rid of those
errors below.
Also I'd like to have a bit more sofisticated hello world example if
possible.
Let's say, I need to import one table from instance1 into instance2 (say
they are both postgres), how do I achieve this with luigi?
Please advise.

$ python3
Python 3.6.9 (default, Jul 17 2020, 12:50:27)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import luigi
>>> class HelloWorldTask(luigi.Task):
... task_namespace = 'examples'
...
>>> def run(self):
File "<stdin>", line 1
def run(self):
^
IndentationError: unexpected indent
>>> print("{task} says: Hello
>>> world!".format(task=self.__class__.__name__))
File "<stdin>", line 1
print("{task} says: Hello
world!".format(task=self.__class__.__name__))
^
IndentationError: unexpected indent
>>>
>>>
>>> if __name__ == '__main__':
... luigi.run(['examples.HelloWorldTask', '--workers', '1',
'--local-scheduler'])
...
DEBUG: Checking if examples.HelloWorldTask() is complete
/home/ymarkiv/.local/lib/python3.6/site-packages/luigi/worker.py:401:
UserWarning: Task examples.HelloWorldTask() without outputs has no
custom complete() method
is_complete = task.complete()
INFO: Informed scheduler that task examples.HelloWorldTask__99914b932b
has status PENDING
INFO: Done scheduling tasks
INFO: Running Worker with 1 processes
DEBUG: Asking scheduler for work...
DEBUG: Pending tasks: 1
INFO: [pid 20605] Worker Worker(salt=641288618, workers=1,
host=marchelloG, username=ymarkiv, pid=20605) running
examples.HelloWorldTask()
INFO: [pid 20605] Worker Worker(salt=641288618, workers=1,
host=marchelloG, username=ymarkiv, pid=20605) done
examples.HelloWorldTask()
DEBUG: 1 running tasks, waiting for next task to finish
INFO: Informed scheduler that task examples.HelloWorldTask__99914b932b
has status DONE
DEBUG: Asking scheduler for work...
DEBUG: Done
DEBUG: There are no more tasks to run at this time
INFO: Worker Worker(salt=641288618, workers=1, host=marchelloG,
username=ymarkiv, pid=20605) was stopped. Shutting down Keep-Alive
thread
INFO:
===== Luigi Execution Summary =====
Scheduled 1 tasks of which:
* 1 ran successfully:
- 1 examples.HelloWorldTask()
This progress looks :) because there were no failed tasks or missing
dependencies
===== Luigi Execution Summary =====
True

Yedam Fv

unread,
Apr 13, 2021, 12:48:33 AM4/13/21
to Luigi
I got the following error but I can not fix it 

(Inspections_dpa) yedam@ip-172-31-22-113:~/Inspections_dpa$ luigid
Traceback (most recent call last):
  File "/home/yedam/.local/bin/luigid", line 7, in <module>
    from luigi.cmdline import luigid
  File "/home/yedam/.local/lib/python2.7/site-packages/luigi/__init__.py", line 23, in <module>
    from luigi import task
  File "/home/yedam/.local/lib/python2.7/site-packages/luigi/task.py", line 145
    class Task(metaclass=Register):
                        ^
SyntaxError: invalid syntax

Any suggestion?

Regards
Yedam

Lars Albertsson

unread,
Apr 13, 2021, 3:01:18 AM4/13/21
to Yedam Fv, Luigi
Luigi does not support python 2.7. You will need to install a recent version of python.

--
You received this message because you are subscribed to the Google Groups "Luigi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to luigi-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/luigi-user/994207bc-19ce-4ee1-bea3-8821a3384605n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages