pythonamazon-web-servicesamazon-s3aws-glueimport-module

how to setup modules in the Glue job script


I'm following this tutorial: https://www.youtube.com/watch?v=EzQArFt_On4

In this tutorial it's only using one python script, what is I need to import some functions from another python script? For example: import script2

I wonder what's the correct way to setup in Glue job? I've tried to store this script in s3 bucket and add the location in editjob -> Security configuration, script libraries, and job parameters (optional) ->Python library path, but it gave me error ModuleNotFoundError: No module named 'script2, does anyone know how to fix this? Thanks.


Solution

  • In the video tutorial there is no such import like import script2. So if you do this in your script and don't provide script2.py library, the import is going to fail with your the message you are getting.

    How to write modules, is best explained in Python docs.

    The best way to start programming glue jobs is to auto-generate glue scripts by glue console. Then you can use the scripts generated as a starting point for customization. What's more you can setup Glue Endpoints or even run glue locally (or on ec2 instance) for learning and development purposes.