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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Option to specify the arg --config-path, -cp as an absolute path #2368

Closed
c-salmi opened this issue Sep 7, 2022 · 3 comments 路 Fixed by #2395
Closed

[Feature Request] Option to specify the arg --config-path, -cp as an absolute path #2368

c-salmi opened this issue Sep 7, 2022 · 3 comments 路 Fixed by #2395
Assignees
Labels
enhancement Enhanvement request
Milestone

Comments

@c-salmi
Copy link

c-salmi commented Sep 7, 2022

馃殌 Feature Request

Option to specify the arg --config-path, -cp as an absolute path.

Motivation

We are working on a new package for local motion planning research. There is a lot of complex configuration required in this project and I think it's a perfect candidate to integrate hydra.

The problem is, it's a package. We would like potential users to be able to install the package (through pypi) and put their configuration files in an arbitrary location. However, currently the config_path arg is relative to the Python file declaring @hydra.main(). In our application @hydra.main() is called within the package, which makes relative paths tricky.

Pitch

Describe the solution you'd like
Would it be possible to check if the specified path in --config-path is absolute or relative, using for instance os.path.isabs(config_path)? If it's an absolute path, we could simply set the search_path to be equal to the config_path. Otherwise we could keep the current behavior.

Describe alternatives you've considered
Alternatively, it could be done using an additional arg specifically for paths relative to the current working directory (or absolute paths).

Are you willing to open a pull request?
Yes

@c-salmi c-salmi added the enhancement Enhanvement request label Sep 7, 2022
@pixelb
Copy link
Contributor

pixelb commented Sep 20, 2022

Yes this makes sense. Thanks

@pixelb pixelb self-assigned this Sep 20, 2022
@pixelb pixelb added this to the Hydra 1.3.0 milestone Sep 20, 2022
pixelb added a commit to pixelb/hydra that referenced this issue Sep 29, 2022
This was actually already supported as
os.path.join("/blah", "/abs/config"), just returns "/abs/config",
but we've made this explicit in code and docs now.
@Jasha10 Jasha10 linked a pull request Sep 29, 2022 that will close this issue
pixelb added a commit to pixelb/hydra that referenced this issue Oct 3, 2022
This was actually already supported as
os.path.join("/blah", "/abs/config"), just returns "/abs/config",
but we've made this explicit in code and docs now.
pixelb added a commit that referenced this issue Oct 4, 2022
This was actually already supported as
os.path.join("/blah", "/abs/config"), just returns "/abs/config",
but we've made this explicit in code and docs now.
@udaylunawat
Copy link

I am facing a similar scenario.

How does one pass the absolute path to config_path in the hydra decorator?

When using
@hydra.main(config_path='/content/configs/', config_name="config", version_base=None)

raises error

Primary config module 'package.directory.configs' not found.
Check that it's correct and contains an __init__.py file

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

The workaround that I am currently using is

pass an argument --config-dir /content/configs

and using the following decorator

@hydra.main(config_path='.', config_name="config", version_base=None)

@Jasha10
Copy link
Collaborator

Jasha10 commented Nov 10, 2022

Hi @udaylunawat,
Support for absolute path as an argument to @hydra.main has not been implemented yet.
This is related to issue #2274.

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

Successfully merging a pull request may close this issue.

4 participants