nexus-extensibility 2.0.0b45__py3-none-any.whl → 2.0.0b46__py3-none-any.whl

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.
@@ -2,14 +2,16 @@ import enum
2
2
  from abc import ABC, abstractmethod
3
3
  from dataclasses import dataclass
4
4
  from datetime import datetime
5
- from typing import (Any, Awaitable, Callable, Dict, List, Optional, Protocol,
6
- Tuple)
5
+ from typing import (Any, Awaitable, Callable, Dict, Generic, List, Optional,
6
+ Protocol, Tuple, TypeVar)
7
7
  from urllib.parse import ParseResult
8
8
 
9
9
  from ._data_model import CatalogItem, CatalogRegistration, ResourceCatalog
10
10
 
11
11
  ################# DATA SOURCE TYPES ###############
12
12
 
13
+ T = TypeVar('T')
14
+
13
15
  class LogLevel(enum.IntEnum):
14
16
  """Defines logging severity levels."""
15
17
 
@@ -37,14 +39,14 @@ class ILogger(ABC):
37
39
  def log(self, log_level: LogLevel, message: str):
38
40
  pass
39
41
 
42
+ # use this syntax in future (3.12+): DataSourceContext[T]
40
43
  @dataclass(frozen=True)
41
- class DataSourceContext:
44
+ class DataSourceContext(Generic[T]):
42
45
  """
43
46
  The starter package for a data source.
44
47
 
45
48
  Args:
46
49
  resource_locator: An optional URL which points to the data.
47
- system_configuration: The system configuration.
48
50
  source_configuration: The source configuration.
49
51
  request_configuration: The request configuration.
50
52
  """
@@ -52,10 +54,7 @@ class DataSourceContext:
52
54
  resource_locator: Optional[ParseResult]
53
55
  """The unique identifier of the package reference."""
54
56
 
55
- system_configuration: Optional[Dict[str, Any]]
56
- """The system configuration."""
57
-
58
- source_configuration: Optional[Dict[str, Any]]
57
+ source_configuration: T
59
58
  """The source configuration."""
60
59
 
61
60
  request_configuration: Optional[Dict[str, Any]]
@@ -104,13 +103,13 @@ class ReadDataHandler(Protocol):
104
103
 
105
104
  ################# DATA SOURCE ###############
106
105
 
107
- class IDataSource(ABC):
106
+ class IDataSource(Generic[T], ABC):
108
107
  """
109
108
  A data source.
110
109
  """
111
110
 
112
111
  @abstractmethod
113
- def set_context(self, context: DataSourceContext, logger: ILogger) -> Awaitable[None]:
112
+ def set_context(self, context: DataSourceContext[T], logger: ILogger) -> Awaitable[None]:
114
113
  """
115
114
  Invoked by Nexus right after construction to provide the context.
116
115
 
@@ -182,12 +181,29 @@ class IDataSource(ABC):
182
181
  """
183
182
  pass
184
183
 
185
- class SimpleDataSource(IDataSource, ABC):
184
+ class IUpgradableDataSource(ABC):
185
+ """
186
+ Data sources which have configuration data to be upgraded should implement this interface.
187
+ """
188
+
189
+ @staticmethod
190
+ @abstractmethod
191
+ def upgrade_source_configuration(configuration: Any) -> Awaitable[Any]:
192
+ """
193
+ Upgrades the source configuration.
194
+
195
+ Args:
196
+ configuration: The configuration.
197
+ """
198
+ pass
199
+
200
+ # use this syntax in future (3.12+): SimpleDataSource[T](...
201
+ class SimpleDataSource(Generic[T], IDataSource[T], ABC):
186
202
  """
187
203
  A simple implementation of a data source.
188
204
  """
189
205
 
190
- Context: DataSourceContext
206
+ Context: DataSourceContext[T]
191
207
  """Gets the data source context. This property is not accessible from within class constructors as it will bet set later."""
192
208
 
193
209
  Logger: ILogger
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nexus-extensibility
3
- Version: 2.0.0b45
3
+ Version: 2.0.0b46
4
4
  Summary: Type definitions to implement data sources for the Nexus system.
5
5
  Home-page: https://github.com/nexus-main/nexus
6
6
  Author: https://github.com/nexus-main
@@ -2,9 +2,9 @@ nexus_extensibility/__init__.py,sha256=temuSqvUeZusU_0j-QoRalMIDfCHm9JP8W6jEO280
2
2
  nexus_extensibility/_data_model.py,sha256=HBuH2ftXAq_a5pJWc5UtqbEEcQIVAolz3xLUYgAHyk0,11964
3
3
  nexus_extensibility/_data_model_extensions.py,sha256=iLSOVDKvVoorj2h0x_XHGhbKwd_NHtrURgS7aUVe8MI,670
4
4
  nexus_extensibility/_data_model_utilities.py,sha256=cb_uJD4CeYz1m7NEttQ7kR3nrcMjovJQCrSUchnglQE,377
5
- nexus_extensibility/_extensibility_data_source.py,sha256=WMQ8_re5CRJLQma4vq0FfRs6hh_WG4eQBC7c5z3tNhI,7095
5
+ nexus_extensibility/_extensibility_data_source.py,sha256=w2LTMMpBXNeNasaF_7YnhNBP_GZ15bk5JW8sFpTHwaI,7530
6
6
  nexus_extensibility/_extensibility_utilities.py,sha256=hQFcY2joHt1goJSCvMfEW5cprN1I-B1-SihqYme8R1A,786
7
- nexus_extensibility-2.0.0b45.dist-info/METADATA,sha256=0PRl3wRxjNYSmqqWqGUiXvA01BpKgboc5IwM3Wndiuk,775
8
- nexus_extensibility-2.0.0b45.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
9
- nexus_extensibility-2.0.0b45.dist-info/top_level.txt,sha256=GTaw9wgS6EKrgO6FhJ3YZuMrkgoK7kP-hW9uybPDbyg,20
10
- nexus_extensibility-2.0.0b45.dist-info/RECORD,,
7
+ nexus_extensibility-2.0.0b46.dist-info/METADATA,sha256=h8aJXu8rWNXAomFwoPpsqwFIZXjKttM26PaqRq_RB6s,775
8
+ nexus_extensibility-2.0.0b46.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
9
+ nexus_extensibility-2.0.0b46.dist-info/top_level.txt,sha256=GTaw9wgS6EKrgO6FhJ3YZuMrkgoK7kP-hW9uybPDbyg,20
10
+ nexus_extensibility-2.0.0b46.dist-info/RECORD,,