What exactly are you trying to achieve ?
Let assume that you have Task.init() in run.py
And run.py
is inside /foo/bar/
If you run :
cd /foo
python bar/run.py
Then the Task will have working folder /foo
If you run:
cd /foo/bar
python run.py
Then your task will have the working folder /foo/bar
The ultimate goal is to make sure run.py
get run under project root directory because the underlying code has this assumption when writing it. Locally pycharm take care of this, but when execute remotely, need to take care of this otherwise it will complain Module Not Found
.
A typical project setup I am working with look like this:
project_root/
|--src/
|--utilities.py
|--foo.py
|--runbooks/
|--run.py
And typical import look like this, for example in foo.py from src.utilities import something
the underlying code has this assumption when writing it
That means that you want to make things work not in a standard Python way ... In which case you need to do "non-standard" things to make it work.
You can do this for example in the beginning of your run.py
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
In this way, you not relying on a non-standard feature to be implemented by your tool like pycharm
or clearml