antelope-interface 0.3.4__tar.gz → 0.3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {antelope_interface-0.3.4/src/antelope_interface.egg-info → antelope_interface-0.3.5}/PKG-INFO +3 -4
  2. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/pyproject.toml +3 -4
  3. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/setup.py +3 -0
  4. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/__init__.py +13 -3
  5. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/interfaces/__init__.py +2 -0
  6. antelope_interface-0.3.5/src/antelope/interfaces/iarchive.py +67 -0
  7. antelope_interface-0.3.5/src/antelope/interfaces/iterm_manager.py +138 -0
  8. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/refs/base.py +2 -4
  9. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/refs/quantity_ref.py +4 -1
  10. {antelope_interface-0.3.4 → antelope_interface-0.3.5/src/antelope_interface.egg-info}/PKG-INFO +3 -4
  11. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope_interface.egg-info/SOURCES.txt +2 -0
  12. antelope_interface-0.3.5/src/antelope_interface.egg-info/requires.txt +2 -0
  13. antelope_interface-0.3.4/src/antelope_interface.egg-info/requires.txt +0 -2
  14. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/LICENSE +0 -0
  15. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/MANIFEST.in +0 -0
  16. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/README.md +0 -0
  17. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/setup.cfg +0 -0
  18. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/exchanges_from_spreadsheet.py +0 -0
  19. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/flows/__init__.py +0 -0
  20. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/flows/flow.py +0 -0
  21. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/flows/flow_interface.py +0 -0
  22. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/flows/openlca_locales.json +0 -0
  23. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/interfaces/abstract_query.py +0 -0
  24. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/interfaces/ibackground.py +0 -0
  25. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/interfaces/ibasic.py +0 -0
  26. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/interfaces/iconfigure.py +0 -0
  27. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/interfaces/iexchange.py +0 -0
  28. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/interfaces/iforeground.py +0 -0
  29. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/interfaces/iindex.py +0 -0
  30. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/interfaces/iquantity.py +0 -0
  31. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/models/__init__.py +0 -0
  32. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/models/auth.py +0 -0
  33. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/models/comparators.py +0 -0
  34. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/qdb/__init__.py +0 -0
  35. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/qdb/qdb.py +0 -0
  36. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/qdb/units.py +0 -0
  37. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/refs/__init__.py +0 -0
  38. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/refs/catalog_ref.py +0 -0
  39. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/refs/exchange_ref.py +0 -0
  40. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/refs/flow_ref.py +0 -0
  41. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/refs/process_ref.py +0 -0
  42. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/refs/tests/__init__.py +0 -0
  43. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/refs/tests/test_flows.py +0 -0
  44. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope/xdb_tokens.py +0 -0
  45. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope_interface.egg-info/dependency_links.txt +0 -0
  46. {antelope_interface-0.3.4 → antelope_interface-0.3.5}/src/antelope_interface.egg-info/top_level.txt +0 -0
@@ -1,21 +1,20 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: antelope_interface
3
- Version: 0.3.4
3
+ Version: 0.3.5
4
4
  Summary: A common interface for accessing LCA data
5
5
  Author-email: Brandon Kuczenski <bkuczenski@ucsb.edu>
6
6
  License: BSD-3-Clause
7
7
  Keywords: one,two
8
8
  Classifier: Development Status :: 4 - Beta
9
9
  Classifier: Intended Audience :: Science/Research
10
- Classifier: License :: OSI Approved :: BSD License
11
10
  Classifier: Natural Language :: English
12
11
  Classifier: Operating System :: OS Independent
13
12
  Classifier: Programming Language :: Python :: 3
14
13
  Classifier: Topic :: Scientific/Engineering
15
- Requires-Python: >=3.6
14
+ Requires-Python: >=3.10
16
15
  Description-Content-Type: text/markdown
17
16
  License-File: LICENSE
18
- Requires-Dist: synonym_dict>=0.2.5
17
+ Requires-Dist: synonym_dict>=0.2.7
19
18
  Requires-Dist: pydantic>=2.5.0
20
19
  Dynamic: license-file
21
20
 
@@ -9,20 +9,19 @@ authors =[
9
9
  ]
10
10
  description = "A common interface for accessing LCA data"
11
11
  readme ={ file = "README.md", content-type = "text/markdown"}
12
- requires-python = ">=3.6"
12
+ requires-python = ">=3.10"
13
13
  keywords = ["one", "two"]
14
14
  license = {text = "BSD-3-Clause"}
15
15
  classifiers = [
16
16
  "Development Status :: 4 - Beta",
17
17
  "Intended Audience :: Science/Research",
18
- "License :: OSI Approved :: BSD License",
19
18
  "Natural Language :: English",
20
19
  "Operating System :: OS Independent",
21
20
  "Programming Language :: Python :: 3",
22
21
  "Topic :: Scientific/Engineering"
23
22
  ]
24
- dependencies = ["synonym_dict >= 0.2.5", "pydantic >= 2.5.0"]
25
- version = "0.3.4"
23
+ dependencies = ["synonym_dict >= 0.2.7", "pydantic >= 2.5.0"]
24
+ version = "0.3.5"
26
25
 
27
26
  [tool.setuptools.packages.find]
28
27
  where = ["src"]
@@ -5,6 +5,9 @@ setup()
5
5
 
6
6
  """
7
7
  Version History:
8
+ 0.3.5 2026/09/25 - Add ArchiveInterface. fix a bug with needy QuantityRefs.
9
+
10
+ 0.3.4.1 - rename 'enum' to 'e_' because that was messed up
8
11
  0.3.4 2026/03/31 - add 'dash' interface type; add 'grant_add' to XDB tokens
9
12
 
10
13
  0.3.3.1 - sanitize process reference exchange in entity model; cached basic queries
@@ -5,7 +5,7 @@ The abstract classes in this sub-package define what information is made availab
5
5
  resource of some kind. The interfaces must be instantiated in order to be used. In the core package
6
6
  """
7
7
 
8
- from .interfaces import ANTELOPE_INTERFACES
8
+ from .interfaces import ANTELOPE_INTERFACES, ArchiveInterface, TermManagerInterface
9
9
 
10
10
  from .interfaces.ibasic import BasicInterface, EntityNotFound, NoAccessToEntity, ItemNotFound
11
11
  from .interfaces.iconfigure import ConfigureInterface
@@ -58,7 +58,7 @@ class BasicQuery(BasicInterface, IndexInterface, ExchangeInterface, QuantityInte
58
58
  - archive.source: returns the physical source (or URI) for the archive's content
59
59
 
60
60
  """
61
- def __init__(self, archive, debug=False, cached=True):
61
+ def __init__(self, archive: ArchiveInterface, debug=False, cached=True):
62
62
  self._archive = archive
63
63
  self._dbg = debug
64
64
  self.cached = cached
@@ -89,6 +89,16 @@ class BasicQuery(BasicInterface, IndexInterface, ExchangeInterface, QuantityInte
89
89
  else:
90
90
  return entity # already a ref
91
91
 
92
+ def get(self, eid, **kwargs):
93
+ """
94
+ A query must return a ref, because the ref encapsulates the query
95
+ :param eid:
96
+ :param kwargs:
97
+ :return:
98
+ """
99
+ entity = self._perform_query('basic', 'get', EntityNotFound, eid, **kwargs)
100
+ return self.make_ref(entity)
101
+
92
102
  def __str__(self):
93
103
  return '%s(%s:%s:%s)' % (self.__class__.__name__, self.origin,
94
104
  self._archive.__class__.__name__,
@@ -155,7 +165,7 @@ def q_node_activity(fg):
155
165
  return fg.get_canonical('node activity')
156
166
 
157
167
 
158
- def enum(iterable, filt=None, invert=True):
168
+ def e_(iterable, filt=None, invert=True):
159
169
  """
160
170
  Enumerate an iterable for interactive use. return it as a list. Optional negative filter supplied as regex.
161
171
 
@@ -1,3 +1,5 @@
1
1
  from .abstract_query import ANTELOPE_INTERFACES
2
2
  from .ibasic import EntityNotFound, NoAccessToEntity, ItemNotFound
3
3
  from .iindex import check_direction, InvalidDirection, InvalidSense
4
+ from .iarchive import ArchiveInterface
5
+ from .iterm_manager import TermManagerInterface
@@ -0,0 +1,67 @@
1
+ """
2
+ Abstract interface for archive providers.
3
+
4
+ An archive is the object stored in ``BasicImplementation._archive`` (and all
5
+ subclass implementations). Any object that satisfies this interface can be
6
+ used as a provider for the standard implementation classes.
7
+
8
+ The surface was derived by auditing every ``self._archive.*`` access across
9
+ ``antelope_core/implementations/*.py``.
10
+ """
11
+
12
+ from abc import abstractmethod
13
+ from typing import runtime_checkable, Protocol
14
+
15
+
16
+ @runtime_checkable
17
+ class ArchiveInterface(Protocol):
18
+ """
19
+ Minimal contract that a provider object must satisfy to work with the
20
+ standard ``*Implementation`` classes in ``antelope_core``.
21
+
22
+ Read-only requirements are marked with ``@property``; methods that may
23
+ mutate the store are marked accordingly in their docstrings.
24
+ """
25
+
26
+ # ------------------------------------------------------------------
27
+ # Identity / metadata
28
+ # ------------------------------------------------------------------
29
+
30
+ @property
31
+ @abstractmethod
32
+ def ref(self) -> str:
33
+ """Semantic reference string used as the archive's origin identifier."""
34
+
35
+ @property
36
+ @abstractmethod
37
+ def source(self) -> str:
38
+ """Physical data source (file path, URL, etc.) — used for display."""
39
+
40
+ # ------------------------------------------------------------------
41
+ # Entity access
42
+ # ------------------------------------------------------------------
43
+
44
+ @abstractmethod
45
+ def __getitem__(self, key):
46
+ """
47
+ Return the already-loaded entity for *key*, or ``None`` if not present.
48
+ Must never raise on a cache miss — return ``None`` instead.
49
+ """
50
+
51
+ @abstractmethod
52
+ def _fetch(self, key, **kwargs):
53
+ """
54
+ Obtain the entity for *key* in a provider-specific way. Raise ``EntityNotFound`` on failure
55
+ """
56
+
57
+ # ------------------------------------------------------------------
58
+ # Interface factory
59
+ # ------------------------------------------------------------------
60
+
61
+ @abstractmethod
62
+ def make_interface(self, itype: str):
63
+ """
64
+ Return an implementation object for the named interface type string
65
+ (``'basic'``, ``'index'``, ``'exchange'``, ``'quantity'``,
66
+ ``'background'``, ``'configure'``).
67
+ """
@@ -0,0 +1,138 @@
1
+ """
2
+ Abstract interface for term manager providers.
3
+
4
+ A term manager is the object stored in ``archive.tm``. It handles synonym
5
+ resolution for flowables and contexts, and manages characterization factors.
6
+
7
+ The surface was derived by auditing every ``self._archive.tm.*`` access across
8
+ ``antelope_core/implementations/*.py``.
9
+ """
10
+
11
+ from abc import ABC, abstractmethod
12
+
13
+
14
+ class TermManagerInterface(ABC):
15
+ """
16
+ Minimal contract that a term manager object must satisfy to work with the
17
+ standard ``*Implementation`` classes in ``antelope_core``.
18
+ """
19
+
20
+ # ------------------------------------------------------------------
21
+ # Identity
22
+ # ------------------------------------------------------------------
23
+
24
+ @property
25
+ @abstractmethod
26
+ def is_lcia_engine(self) -> bool:
27
+ """
28
+ True if this term manager operates as a full LCIA engine — i.e. it
29
+ uses a standard canonical set of flowables and contexts and can match
30
+ synonyms across data sources. False for a provincial term manager
31
+ that treats its own archive as the sole source of truth.
32
+ """
33
+
34
+ # ------------------------------------------------------------------
35
+ # Lookup
36
+ # ------------------------------------------------------------------
37
+
38
+ @abstractmethod
39
+ def __getitem__(self, term):
40
+ """
41
+ Look up *term* and return the matching ``Context`` (or flowable
42
+ canonical name), or ``None`` if not found. *term* may be a string
43
+ synonym, a ``Context`` object, or ``None``.
44
+
45
+ Used by ``BasicImplementation.get_context`` and
46
+ ``QuantityImplementation._get_flowable_info``.
47
+ """
48
+
49
+ @abstractmethod
50
+ def get_flowable(self, flow):
51
+ """
52
+ Return the canonical flowable name for *flow*.
53
+ Raises ``KeyError`` if not recognised.
54
+
55
+ Used by ``IndexImplementation.unmatched_flows``.
56
+ """
57
+
58
+ @abstractmethod
59
+ def get_canonical(self, quantity):
60
+ """
61
+ Return the canonical quantity entity for *quantity* (which may be a
62
+ string external_ref or a quantity object).
63
+ Raises ``EntityNotFound`` if not recognised.
64
+
65
+ Used by ``QuantityImplementation.get_canonical`` and related helpers.
66
+ """
67
+
68
+ # ------------------------------------------------------------------
69
+ # Enumeration
70
+ # ------------------------------------------------------------------
71
+
72
+ @abstractmethod
73
+ def synonyms(self, item):
74
+ """
75
+ Generate synonym strings for the given flowable or context *item*.
76
+
77
+ Used by ``BasicImplementation.synonyms``.
78
+ """
79
+
80
+ @abstractmethod
81
+ def flowables(self, **kwargs):
82
+ """
83
+ Generate canonical flowable name strings, optionally filtered by
84
+ keyword arguments.
85
+
86
+ Used by ``IndexImplementation.flowables``.
87
+ """
88
+
89
+ @abstractmethod
90
+ def contexts(self, **kwargs):
91
+ """
92
+ Generate ``Context`` objects known to this term manager, optionally
93
+ filtered by keyword arguments.
94
+
95
+ Used by ``IndexImplementation.contexts``.
96
+ """
97
+
98
+ # ------------------------------------------------------------------
99
+ # Characterization factors
100
+ # ------------------------------------------------------------------
101
+
102
+ @abstractmethod
103
+ def factors_for_quantity(self, quantity, flowable=None, context=None, dist=0):
104
+ """
105
+ Generate ``Characterization`` objects for the given canonical
106
+ *quantity*, optionally filtered by *flowable* and *context*.
107
+
108
+ *dist* controls context-matching strictness:
109
+ 0 = exact match, 1 = child contexts, 2 = parent context,
110
+ 3 = any ancestor including NullContext.
111
+
112
+ Used by ``QuantityImplementation.factors``.
113
+ """
114
+
115
+ @abstractmethod
116
+ def factors_for_flowable(self, flowable, quantity=None, context=None, **kwargs):
117
+ """
118
+ Generate ``Characterization`` objects for the given canonical
119
+ *flowable* string, optionally filtered by *quantity* and *context*.
120
+
121
+ Used by ``QuantityImplementation._quantity_engine`` and
122
+ ``_ref_qty_conversion``.
123
+ """
124
+
125
+ @abstractmethod
126
+ def add_characterization(self, flowable, ref_quantity, query_quantity,
127
+ value, context=None, location='GLO', origin=None,
128
+ **kwargs):
129
+ """
130
+ Store a characterization factor: 1 unit of *ref_quantity* of
131
+ *flowable* in *context* equals *value* units of *query_quantity*.
132
+
133
+ *location* defaults to ``'GLO'``; *origin* defaults to the archive's
134
+ own ``ref`` string when called from ``ConfigureImplementation``.
135
+
136
+ Used by ``QuantityImplementation.characterize`` and
137
+ ``ConfigureImplementation.characterize_flow``.
138
+ """
@@ -165,16 +165,14 @@ class BaseRef(BaseEntity):
165
165
 
166
166
  def __eq__(self, other):
167
167
  """
168
- Catalog refs are equal if their external_refs are equal and their origins start with each other
168
+ Catalog refs are equal if their links are equal
169
169
  :param other:
170
170
  :return:
171
171
  """
172
172
  if other is None:
173
173
  return False
174
174
  try:
175
- return ( # (other.entity_type == 'unknown' or self.entity_type == other.entity_type) and
176
- self.external_ref == other.external_ref and
177
- (self.origin.startswith(other.origin) or other.origin.startswith(self.origin)))
175
+ return self.link == other.link
178
176
  except AttributeError:
179
177
  return False
180
178
 
@@ -16,6 +16,7 @@ but it depends on the LciaResult implementation, which is irretrievably part of
16
16
  """
17
17
 
18
18
  from ..flows import FlowInterface
19
+ from ..interfaces.ibasic import ItemNotFound, EntityNotFound
19
20
  from .base import EntityRef
20
21
  from synonym_dict import LowerDict
21
22
 
@@ -160,13 +161,15 @@ class QuantityRef(EntityRef):
160
161
  yield self.uuid
161
162
  if self.origin is not None:
162
163
  yield self.link
163
- if self.has_property('Synonyms'):
164
+ try:
164
165
  syns = self['Synonyms']
165
166
  if isinstance(syns, str):
166
167
  yield syns
167
168
  else:
168
169
  for syn in syns:
169
170
  yield syn
171
+ except (KeyError, ItemNotFound, EntityNotFound):
172
+ pass
170
173
 
171
174
  """
172
175
  Interface methods
@@ -1,21 +1,20 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: antelope_interface
3
- Version: 0.3.4
3
+ Version: 0.3.5
4
4
  Summary: A common interface for accessing LCA data
5
5
  Author-email: Brandon Kuczenski <bkuczenski@ucsb.edu>
6
6
  License: BSD-3-Clause
7
7
  Keywords: one,two
8
8
  Classifier: Development Status :: 4 - Beta
9
9
  Classifier: Intended Audience :: Science/Research
10
- Classifier: License :: OSI Approved :: BSD License
11
10
  Classifier: Natural Language :: English
12
11
  Classifier: Operating System :: OS Independent
13
12
  Classifier: Programming Language :: Python :: 3
14
13
  Classifier: Topic :: Scientific/Engineering
15
- Requires-Python: >=3.6
14
+ Requires-Python: >=3.10
16
15
  Description-Content-Type: text/markdown
17
16
  License-File: LICENSE
18
- Requires-Dist: synonym_dict>=0.2.5
17
+ Requires-Dist: synonym_dict>=0.2.7
19
18
  Requires-Dist: pydantic>=2.5.0
20
19
  Dynamic: license-file
21
20
 
@@ -12,6 +12,7 @@ src/antelope/flows/flow_interface.py
12
12
  src/antelope/flows/openlca_locales.json
13
13
  src/antelope/interfaces/__init__.py
14
14
  src/antelope/interfaces/abstract_query.py
15
+ src/antelope/interfaces/iarchive.py
15
16
  src/antelope/interfaces/ibackground.py
16
17
  src/antelope/interfaces/ibasic.py
17
18
  src/antelope/interfaces/iconfigure.py
@@ -19,6 +20,7 @@ src/antelope/interfaces/iexchange.py
19
20
  src/antelope/interfaces/iforeground.py
20
21
  src/antelope/interfaces/iindex.py
21
22
  src/antelope/interfaces/iquantity.py
23
+ src/antelope/interfaces/iterm_manager.py
22
24
  src/antelope/models/__init__.py
23
25
  src/antelope/models/auth.py
24
26
  src/antelope/models/comparators.py
@@ -0,0 +1,2 @@
1
+ synonym_dict>=0.2.7
2
+ pydantic>=2.5.0
@@ -1,2 +0,0 @@
1
- synonym_dict>=0.2.5
2
- pydantic>=2.5.0