Skip to content

Allow overriding the resource registry #198

Description

@de-code

I was trying to use delft version 0.4.0/master via GitHub (as it isn't on pypi yet). (see sciencebeam-trainer-delft draft PR)

One issue trying to use delft.sequenceLabelling.wrapper.Sequence is that the resource registry path is hard coded and it would look for .venv/lib/python3.11/site-packages/delft/resources-registry.json' which doesn't exist (not sure if it would exist if it was in pypi).

Currently in master:

from delft import DELFT_PROJECT_DIR

...
        self.registry = load_resource_registry(os.path.join(DELFT_PROJECT_DIR, "resources-registry.json"))

DELFT_PROJECT_DIR resolves to the package directory in site-packages.

In 0.3.4 that was a relative path:

        self.registry = load_resource_registry("delft/resources-registry.json")

For my use case, I don't even use embedding vectors most of the time. If I do, I'd like to have control over it as well (I have a separate EmbeddingManager, I can't quite remember for what purpose but dynamically loading embedding files was probably one of the reasons).

So I would like to be able to avoid loading the registry unless needed, and be able to influence loading instances of Embedding.

Suggested options:

  • add a function like get_embedding(self, embedding_name: str)., I can override it, default can dynamically load registry.
  • or optional parameter for registry
  • or optional parameter for resource registry path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions