Skip to content

Commit b0fb691

Browse files
kjlippoldKen Lippold
andauthored
299 celery etl (#20)
* Refactored etl module to use jobs and tasks API * Fixed old references to payloads * Uptick version * Renamed Job to DataConnection * Added ETL local exec option * Updated version --------- Co-authored-by: Ken Lippold <klippold@Kens-MacBook-Pro-2.local>
1 parent c8ee03a commit b0fb691

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+835
-755
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ install_requires =
1919
numpy >= 1.22.4
2020
pyyaml >= 5
2121
simplejson >= 3
22-
crontab >= 1
22+
python-crontab >= 3
2323
python-dateutil >= 2.8.2
2424
croniter >= 2.0.1
2525
jmespath >= 1.0.1

src/hydroserverpy/api/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
SensorService,
1313
DatastreamService,
1414
OrchestrationSystemService,
15-
DataSourceService,
16-
DataArchiveService,
15+
DataConnectionService,
16+
TaskService,
1717
)
1818

1919

@@ -191,13 +191,13 @@ def orchestrationsystems(self):
191191
return OrchestrationSystemService(self)
192192

193193
@property
194-
def datasources(self):
195-
"""Utilities for managing HydroServer data sources."""
194+
def dataconnections(self):
195+
"""Utilities for managing HydroServer ETL data connections."""
196196

197-
return DataSourceService(self)
197+
return DataConnectionService(self)
198198

199199
@property
200-
def dataarchives(self):
201-
"""Utilities for managing HydroServer data archives."""
200+
def tasks(self):
201+
"""Utilities for managing HydroServer ETL tasks."""
202202

203-
return DataArchiveService(self)
203+
return TaskService(self)

src/hydroserverpy/api/models/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
from .sta.thing import Thing
1414
from .sta.unit import Unit
1515
from .etl.orchestration_system import OrchestrationSystem
16-
from .etl.data_source import DataSource
17-
from .etl.data_archive import DataArchive
16+
from .etl.data_connection import DataConnection
17+
from .etl.run import TaskRun
18+
from .etl.task import Task
19+
from .etl.mapping import TaskMapping
1820

1921
Workspace.model_rebuild()
2022
Role.model_rebuild()
Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
1-
from .extractors import Extractor, HTTPExtractor, LocalFileExtractor, FTPExtractor
2-
from .transformers import JSONTransformer, CSVTransformer, Transformer
3-
from .loaders import HydroServerLoader, Loader
4-
5-
from .etl_configuration import EtlConfiguration
6-
from .schedule import Schedule
7-
from .status import Status
81
from .orchestration_system import OrchestrationSystem
9-
from .data_source import DataSource
2+
from .data_connection import DataConnection
3+
from .task import Task
4+
from .schedule import TaskSchedule
5+
from .run import TaskRun
106

117
__all__ = [
12-
"CSVTransformer",
13-
"JSONTransformer",
14-
"LocalFileExtractor",
15-
"FTPExtractor",
16-
"HTTPExtractor",
17-
"Extractor",
18-
"Transformer",
19-
"Loader",
20-
"HydroServerLoader",
21-
"EtlConfiguration",
22-
"Schedule",
23-
"Status",
248
"OrchestrationSystem",
25-
"DataSource",
9+
"DataConnection",
10+
"Task",
11+
"TaskSchedule",
12+
"TaskRun"
2613
]

src/hydroserverpy/api/models/etl/data_archive.py

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import uuid
2+
from typing import ClassVar, List, Optional, TYPE_CHECKING
3+
from pydantic import Field, AliasPath, AliasChoices
4+
from ..base import HydroServerBaseModel
5+
6+
if TYPE_CHECKING:
7+
from hydroserverpy import HydroServer
8+
from hydroserverpy.api.models import Workspace, Task
9+
10+
11+
class DataConnection(HydroServerBaseModel):
12+
name: str = Field(..., max_length=255)
13+
data_connection_type: str = Field(..., max_length=255, alias="type")
14+
workspace_id: Optional[uuid.UUID] = Field(
15+
None, validation_alias=AliasChoices("workspaceId", AliasPath("workspace", "id"))
16+
)
17+
extractor_type: str = Field(..., max_length=255, validation_alias=AliasPath("extractor", "type"))
18+
extractor_settings: dict = Field(default_factory=dict, validation_alias=AliasPath("extractor", "settings"))
19+
transformer_type: str = Field(..., max_length=255, validation_alias=AliasPath("transformer", "type"))
20+
transformer_settings: dict = Field(default_factory=dict, validation_alias=AliasPath("transformer", "settings"))
21+
loader_type: str = Field(..., max_length=255, validation_alias=AliasPath("loader", "type"))
22+
loader_settings: dict = Field(default_factory=dict, validation_alias=AliasPath("loader", "settings"))
23+
24+
_editable_fields: ClassVar[set[str]] = {
25+
"name",
26+
"data_connection_type",
27+
"extractor_type",
28+
"extractor_settings",
29+
"transformer_type",
30+
"transformer_settings",
31+
"loader_type",
32+
"loader_settings",
33+
}
34+
35+
def __init__(self, client: "HydroServer", **data):
36+
super().__init__(client=client, service=client.dataconnections, **data)
37+
38+
self._workspace = None
39+
self._tasks = None
40+
41+
@classmethod
42+
def get_route(cls):
43+
return "etl-data-connections"
44+
45+
@property
46+
def workspace(self) -> "Workspace":
47+
"""The workspace this ETL data connection belongs to."""
48+
49+
if self._workspace is None and self.workspace_id:
50+
self._workspace = self.client.workspaces.get(uid=self.workspace_id)
51+
52+
return self._workspace
53+
54+
@property
55+
def tasks(self) -> List["Task"]:
56+
"""The ETL tasks associated with this ETL data connection."""
57+
58+
if self._tasks is None:
59+
self._tasks = self.client.tasks.list(
60+
data_connection=self.uid, fetch_all=True
61+
).items
62+
63+
return self._tasks

src/hydroserverpy/api/models/etl/data_source.py

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)