question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I would like to be able to “locally” register a plugin, within a bounded context. An example would be a library where I know, locally that I would be dealing with “.dat” / “.raw” files which actually have a certain binary format, so I want to register a plugin for these, but I don’t want this plugin to affect the entire Python process (because “.dat”/“.raw” could be anything, and I don’t want to make promises for other modules in the same process that could also be using imageio). IOW, I’d like something like (API names up to bikeshedding)

def my_libs_public_api(path: Path, ...):
    # path can be a .dat/.raw, or perhaps any other format supported by imageio
    imopen_with_extra_plugins = imopen.with_plugins(extra_plugins)  # perhaps instantiated at module level
    with imopen_with_extra_plugins(path, "r") as file: return file.read()

I think this is “mostly” just a matter of having an extra class attribute _instance_plugins, which is checked before _known_plugins, have with_plugins return a new imopen instance with extra entries in _instance_plugins, and check _instance_plugins before _known_plugins in imopen.__call__.

Thoughts?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
FirefoxMetzgercommented, Nov 5, 2021

Awesome.

@almarklein Any objections to extending support of plugin in imopen(..., plugin=...) to allow plugin classes as input?

@anntzer Would you be interested in contributing this feature?

0reactions
anntzercommented, Nov 5, 2021

Not now, but I’ll keep this somewhere in the back of my mind.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Local plugins - MoodleDocs
Local plugins are used in cases when no standard plugin fits, examples are: event consumers communicating with external systems; custom ...
Read more >
Creating a Local Plugin - Gatsby
If a plugin is only relevant to your specific use-case, or if you're developing a plugin and want a simpler workflow, a locally...
Read more >
Local plugins | Moodle Developer Resources
Local plugins. The recommended way to add new functionality to Moodle is to create a new standard plugin (for example, activity, block, ...
Read more >
Local plugins - Strapi Developer Documentation
Strapi allows you to create your own custom local plugins that will work exactly the same as external ones.
Read more >
Writing local plugins | Snapcraft documentation
Writing local plugins · Step 1: Create new project · Step 2: Create new plugin · Step 3: Write plugin · Step 4:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found