Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import user scripts outside the working directory if user_script is relative to config file #1540

Open
tezheng opened this issue Jan 8, 2025 · 1 comment

Comments

@tezheng
Copy link
Contributor

tezheng commented Jan 8, 2025

Describe the bug
Cannot import user scripts outside the working directory if user_script/script_dir is relative to config file.

To Reproduce

  • Put workflow.json and user_script.py under D:/project/
  • cd D:/, then olive run --config ./project/workflow.json

Olive config

  "data_configs": [
    {
      "name": "quant_data_config",
      "user_script": "imagenet.py",
      "dataloader_config": {
        "type": "mobilenet_calibration_reader",
        "data_dir": "data/imagenet_subset/train",
        "batch_size": 1
      }
    }
  ]

Olive logs

pydantic.v1.error_wrappers.ValidationError: 6 validation errors for RunConfig
data_configs -> __root__
  D:\NPU\NPU-Examples\imagenet.py doesn't exist (type=value_error)
evaluators -> common_evaluator
  metric_data_config not found in {} (type=value_error)
engine
  Invalid evaluators (type=value_error)
passes -> conversion
  Invalid engine (type=value_error)
passes -> qnn_preprocess
  Invalid engine (type=value_error)
passes -> quantization
  Invalid engine (type=value_error)

Other information

  • OS: Any
  • Olive version: 0.7.1.1
  • ONNXRuntime package and version: onnxruntime-qnn==1.20.0
  • Transformers package version: 4.47.1

Additional context
Specifying script_dir does not help as well (which will be insert into sys.path) as existence checking of script_dir is done with Path.resolve

@jambayk
Copy link
Contributor

jambayk commented Jan 8, 2025

Hi, thanks for opening this issue.

As mentioned in the linked PR, the path to user_script is relative to where the olive command is called from. This also applies to any path that is provided in the config such as data_dir. In order to make this work, the config needs to be updated to have "user_script": "project/imagenet.py"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants