outerport / paramit

Parameterize Python scripts/notebooks all from the command line and run on cloud GPUs
Apache License 2.0
96 stars 11 forks source link

A way to refer to 'script_path' in the python script? #72

Closed squidrice21 closed 3 months ago

squidrice21 commented 3 months ago

Is it possible to get this haipera meta value on the script side? script_path = "/xxx/yyy.py" The context is that I want to use a script to call another script in the repo but can’t set the path the regular way due to the haipera wrapping (aka __file__ no longer works).

E.g., I'm currently using absolution path like this:

# This doesn't work since haipera launches a duplication of the original script
# SOME_PY = os.path.abspath(os.path.split(
#     os.path.abspath(__file__))[0]+'/xxx/yyy.py')
SOME_PY = '/zzz/xxx/yyy.py' # This absolution path is not machine indepedent
4cardbot commented 3 months ago

A similar issue occurs if I use os.getcwd() in the script to fetch the current directory for a similar use-case.