Select to view content in your preferred language

Scripts not used by main script do not upload when publishing

06-11-2024 04:19 PM
Occasional Contributor

I have a python tool with the following structure:

  • Script folder
    • (the script that the GP tool points to)

The imports, and imports Importantly, does not directly import

When I publish via Pro's Share as Web Tool, the and will upload, but will not. Based on testing it seems like is not uploading because it is not directly called by the "main" script that the GP tool points to.

Is there a way to get all scripts in the folder to upload, even if not directly called by the main_script?


Note - There are clunky workarounds: One is to manually copy over But that's a cumbersome step, especially when I have to do it on a frequent basis. Another option is I could just import them into the main script even if I don't use them, which would ensure they upload, but it's poor practice to import modules you don't use (wastes memory and has potential to create confusion later).



PS - I feel like @DanPatterson or @Luke_Pinner might have some useful insights on this.



0 Kudos
2 Replies
MVP Esteemed Contributor

importing the isn't going to increase memory useage, it just imports function names into python namespace.

import module as m   # you can them import specify functions from `m`  

import module_helper as mh  # just assigns `mh` into the namespace

perhaps try that to see if it enables importing of the helper... I don't do web tools so I will defer to others

A toolbox `atbx` offers an alternative since you can put all the other *.py files into a folder 

... sort of retired...
0 Kudos
Occasional Contributor

Thanks for clarifying, Dan.

I tried adding import module_helper in the main script without using it anywhere in the main script, but it still didn't copy over during publishing. So seems like it not only has to be imported but actually used in the main script?


0 Kudos