How to use class found in module located in working directory

8 views
Skip to first unread message

andrea...@gmail.com

unread,
Oct 18, 2019, 10:00:12 AM10/18/19
to Hops
How do I call a class or function from a module located in my working directory? 

Just 

"from module import class",

as I would do if I were running the program locally doesn't work. 

Best Regars,

Andreas

Robin

unread,
Oct 18, 2019, 1:56:11 PM10/18/19
to andrea...@gmail.com, Hops
Hi Andreas! 

The python modules are stored on HDFS, which means python will not find the modules when you try to import external modules in your notebook. However we have a helper method which downloads either a .py file or .ipynb file and makes it importable.

Alternatively, you can click the "Advanced" option where you configure Jupyter in Hopsworks and select the .py files you want to be uploaded to your notebook. (This solution would only work in the PySpark kernel).

add_py_file.png

BR,
Robin


--
You received this message because you are subscribed to the Google Groups "Hops" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hopshadoop+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hopshadoop/21abd948-3d4f-4d09-97e5-5c7f0cf4d30b%40googlegroups.com.

andrea...@gmail.com

unread,
Oct 28, 2019, 10:20:05 AM10/28/19
to Hops
This worked for my modules, thank you! However, when I used the "Advanced" option to upload a file, the job returned with a "file not found error". It did finish successfully using hdfs.copy_to_local(hdfs.project_path() + path-to-file), on the other hand. Only after I had reuploaded the file did both alternatives work, which I find a bit odd.

Best Regards,

Andreas
Reply all
Reply to author
Forward
0 new messages