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

Allow users to provide a filesystem path to a Python file for callbacks #159

Closed
jeremycline opened this issue Apr 15, 2019 · 0 comments · Fixed by #162
Closed

Allow users to provide a filesystem path to a Python file for callbacks #159

jeremycline opened this issue Apr 15, 2019 · 0 comments · Fixed by #162
Labels
enhancement New feature or request

Comments

@jeremycline
Copy link
Member

Currently, the callback must be in the PYTHONPATH and is specified by "package.module:function" in the configuration. This is convenient when you already have the function in the Python path and the callback is part of a bigger project.

However, for one-off scripts it's more convenient to provide a path to the file (some/python/file.py:function) than it is to make a Python package for the callback alone.

We should add support to the consume CLI to accept a filesystem path as well as a Python path. It'll need to differentiate the two types. If a relative path is given to a file in the current directory (e.g. "callback.py:my_function") we can't tell the difference between the PYTHONPATH variety and the filesystem path, so I think we should always default to first trying the PYTHONPATH, then falling back to interpreting it as a filesystem path, then failing.

@abompard abompard added the enhancement New feature or request label Apr 15, 2019
jeremycline added a commit to jeremycline/fedora-messaging that referenced this issue Apr 17, 2019
Previously, the callback needed to reside on the Python Path, which is
convenient if you're already making a Python package. Plenty of folks
aren't, though, so allow users to provide a file that we'll boldly exec
and load a callback from.

Fixes fedora-infra#159

Signed-off-by: Jeremy Cline <jcline@redhat.com>
mergify bot pushed a commit that referenced this issue May 16, 2019
Previously, the callback needed to reside on the Python Path, which is
convenient if you're already making a Python package. Plenty of folks
aren't, though, so allow users to provide a file that we'll boldly exec
and load a callback from.

Fixes #159

Signed-off-by: Jeremy Cline <jcline@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants