-
Notifications
You must be signed in to change notification settings - Fork 468
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
multiple independent packages, each with its own registry within a larger program #623
Comments
The way I usually implemented this by having a flag in the subpackages to use pint's _DEFAULT_REGISTRY (usually through an environmental variable). The problem is when multiple packages have incompatible sets of units in which case is not possible with pint (but also is not logically possible) |
I see. I also found #108 where you discussed this topic, it just did not come up when I googled it. I have a rather simple case (civil engineers usually don't define anything new) so using an unmodified default registry will solve my issues. Thanks for the answer! |
Maybe the "fix" could be included as a note in the documentation, to spare later user the search? |
My solution for the current issue was:
instead of
and it seems to work; I don't know about side effects though. |
There are no side effects of this but maybe we could find a better API and document it. |
how about |
The current master has a default registry and an API to set the application registry. This should cover most applications. Feel free to reopen if needed. |
Cool, thank you! |
See #880 as a starting point. Feedback about the docs would be appreciated. |
Thank you for the pointer! I would suggest adding docs (maybe here would be a good spot) explaining how to do what the OP asks. I'll give a suggestion/template here of what I think makes sense, but I can't fill it out fully since I don't actually know what the "proper way is": Interoperation between pint-using packagesWhen different packages and modules use pint, the proper handling of unit registries is critical. In addition, often you don't have access/freedom to change other people's code yourself. As a package author, you want to ensure that other people can easily work with your code. As an application author, you come into the situation where you use more than one pint-using package, and want to avoid clashes between three codebases. Below we lay out a good structure how different packages modules, both packages and applications, can interoperate with each other when using pint. Let's assume we have the following package structure, which should cover the majority of usecases. All packages make use of pint, and use the default registry if not otherwise indicated. Some are "unitful code providers", some "unitful code consumers", some both.
A sketch:
To enable all these packages to play nice with each other (
|
The documentation says, quantities from different registries can not be used together. What happens if I have multiple packages developed independently, each with its own registry and want to use these in a larger program that uses said packages and the packages must communicate e.g. taking a result from package A and using it in package B.
As far as I understand the current logic, this would not work as simply importing the packages would break stuff. Is there a way to avoid having to implement some kind of a data exchange layer?
The text was updated successfully, but these errors were encountered: