Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.53k stars 2.76k forks source link

Command does not add root folder to python path #29724

Open MalcolmMielle opened 1 year ago

MalcolmMielle commented 1 year ago

I have a package that looks like that:

package_name
  |--file.py
scripts
  |--azure
  | |--launch.py
  |--a_script.py

in launch.py I have

job = command(
        inputs=job_inputs,
        outputs=job_outputs,
        code=".",  # location of source code
        command=(
            "python3.10 scripts/a_script.py"
        ),
        environment=environment + "@latest",
        compute="nerf-T4-gpu-aml",
        experiment_name="colmap_v2",
    )

And a_script.py as an import from package_name.file import File. When running the job I am hit with the error: ModuleNotFoundError: No module named 'package_name'. It seems like the root folder, while exported to the job is not added to the python path as it was with the SDK v1.

MalcolmMielle commented 1 year ago

Adding:

sys.path
sys.path.append(".")

to a_script.py solves the problem somehow

tjprescott commented 1 year ago

@MalcolmMielle what SDK are you attempting to use?

MalcolmMielle commented 1 year ago

I'm using azure ml sdk2 installed with "pip install azure-ai-ml". I'll check the exact version tomorrow

tjprescott commented 1 year ago

Thanks. @luigiw @azureml-github can you please take a look at this issue and assist @MalcolmMielle?