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

Load resource_files from external project #2945

Open
LecrisUT opened this issue May 20, 2024 · 0 comments
Open

Load resource_files from external project #2945

LecrisUT opened this issue May 20, 2024 · 0 comments

Comments

@LecrisUT
Copy link
Contributor

Issue

Right now most of the resources are searched through resource_files, but if other projects want to inject files there, e.g. json schemas, there is no way to make it searchable.

Approach 1

Extend resource_files to allow more general Traversable types:

tmt/tmt/utils.py

Lines 7028 to 7030 in b782a60

def resource_files(path: Union[str, Path], package: Union[str, ModuleType] = "tmt") -> Path:
"""
Helper function to get path of package file or directory.

This is in order to allow the usage of MultiplexedPath, where the roots are package="tmt" and entry-point tmt.resources

Difficulty: For this approach, many implementation must be generalized from Path to Traversable until the final item where it will be cast to Path. For the most part as I navigated, there doesn't seem to be much issue except for tmt.utils.load_schema_store where glob is used. In principle that could be handled by using iterdir instead.

Approach 2

For each resource_files implement a search mechanism to look in each entry-point.

Difficulty:

  • How to convert variables like TEMPLATES_DIRECTORY?
  • Increased complexity since this search will now be done near each execution of resource_files
  • Will not be able to support native MultiplexedPath e.g. from namespaced packages of the third-party project
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

1 participant