tmt icon indicating copy to clipboard operation
tmt copied to clipboard

Load `resource_files` from external project

Open LecrisUT opened this issue 9 months ago • 0 comments

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: https://github.com/teemtee/tmt/blob/b782a6067f4c2f8f2a10318edd3a6b06ccced5de/tmt/utils.py#L7028-L7030

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

LecrisUT avatar May 20 '24 16:05 LecrisUT