apache-hamilton 1.90.0.dev0__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.
- apache_hamilton-1.90.0.dev0.dist-info/METADATA +407 -0
- apache_hamilton-1.90.0.dev0.dist-info/RECORD +151 -0
- apache_hamilton-1.90.0.dev0.dist-info/WHEEL +4 -0
- apache_hamilton-1.90.0.dev0.dist-info/entry_points.txt +9 -0
- apache_hamilton-1.90.0.dev0.dist-info/licenses/DISCLAIMER +10 -0
- apache_hamilton-1.90.0.dev0.dist-info/licenses/LICENSE +228 -0
- apache_hamilton-1.90.0.dev0.dist-info/licenses/NOTICE +5 -0
- hamilton/__init__.py +24 -0
- hamilton/ad_hoc_utils.py +132 -0
- hamilton/async_driver.py +465 -0
- hamilton/base.py +466 -0
- hamilton/caching/__init__.py +16 -0
- hamilton/caching/adapter.py +1475 -0
- hamilton/caching/cache_key.py +70 -0
- hamilton/caching/fingerprinting.py +287 -0
- hamilton/caching/stores/__init__.py +16 -0
- hamilton/caching/stores/base.py +242 -0
- hamilton/caching/stores/file.py +140 -0
- hamilton/caching/stores/memory.py +297 -0
- hamilton/caching/stores/sqlite.py +282 -0
- hamilton/caching/stores/utils.py +40 -0
- hamilton/cli/__init__.py +16 -0
- hamilton/cli/__main__.py +328 -0
- hamilton/cli/commands.py +126 -0
- hamilton/cli/logic.py +338 -0
- hamilton/common/__init__.py +76 -0
- hamilton/contrib/__init__.py +41 -0
- hamilton/data_quality/__init__.py +16 -0
- hamilton/data_quality/base.py +198 -0
- hamilton/data_quality/default_validators.py +560 -0
- hamilton/data_quality/pandera_validators.py +121 -0
- hamilton/dataflows/__init__.py +726 -0
- hamilton/dataflows/template/README.md +25 -0
- hamilton/dataflows/template/__init__.py +54 -0
- hamilton/dataflows/template/author.md +28 -0
- hamilton/dataflows/template/requirements.txt +0 -0
- hamilton/dataflows/template/tags.json +7 -0
- hamilton/dataflows/template/valid_configs.jsonl +1 -0
- hamilton/dev_utils/__init__.py +16 -0
- hamilton/dev_utils/deprecation.py +204 -0
- hamilton/driver.py +2112 -0
- hamilton/execution/__init__.py +16 -0
- hamilton/execution/debugging_utils.py +56 -0
- hamilton/execution/executors.py +502 -0
- hamilton/execution/graph_functions.py +421 -0
- hamilton/execution/grouping.py +430 -0
- hamilton/execution/state.py +539 -0
- hamilton/experimental/__init__.py +27 -0
- hamilton/experimental/databackend.py +61 -0
- hamilton/experimental/decorators/__init__.py +16 -0
- hamilton/experimental/decorators/parameterize_frame.py +233 -0
- hamilton/experimental/h_async.py +29 -0
- hamilton/experimental/h_cache.py +413 -0
- hamilton/experimental/h_dask.py +28 -0
- hamilton/experimental/h_databackends.py +174 -0
- hamilton/experimental/h_ray.py +28 -0
- hamilton/experimental/h_spark.py +32 -0
- hamilton/function_modifiers/README +40 -0
- hamilton/function_modifiers/__init__.py +121 -0
- hamilton/function_modifiers/adapters.py +900 -0
- hamilton/function_modifiers/base.py +859 -0
- hamilton/function_modifiers/configuration.py +310 -0
- hamilton/function_modifiers/delayed.py +202 -0
- hamilton/function_modifiers/dependencies.py +246 -0
- hamilton/function_modifiers/expanders.py +1230 -0
- hamilton/function_modifiers/macros.py +1634 -0
- hamilton/function_modifiers/metadata.py +434 -0
- hamilton/function_modifiers/recursive.py +908 -0
- hamilton/function_modifiers/validation.py +289 -0
- hamilton/function_modifiers_base.py +31 -0
- hamilton/graph.py +1153 -0
- hamilton/graph_types.py +264 -0
- hamilton/graph_utils.py +41 -0
- hamilton/htypes.py +450 -0
- hamilton/io/__init__.py +32 -0
- hamilton/io/data_adapters.py +216 -0
- hamilton/io/default_data_loaders.py +224 -0
- hamilton/io/materialization.py +500 -0
- hamilton/io/utils.py +158 -0
- hamilton/lifecycle/__init__.py +67 -0
- hamilton/lifecycle/api.py +833 -0
- hamilton/lifecycle/base.py +1130 -0
- hamilton/lifecycle/default.py +802 -0
- hamilton/log_setup.py +47 -0
- hamilton/models.py +92 -0
- hamilton/node.py +449 -0
- hamilton/plugins/README.md +48 -0
- hamilton/plugins/__init__.py +16 -0
- hamilton/plugins/dask_extensions.py +47 -0
- hamilton/plugins/dlt_extensions.py +161 -0
- hamilton/plugins/geopandas_extensions.py +49 -0
- hamilton/plugins/h_dask.py +331 -0
- hamilton/plugins/h_ddog.py +522 -0
- hamilton/plugins/h_diskcache.py +163 -0
- hamilton/plugins/h_experiments/__init__.py +22 -0
- hamilton/plugins/h_experiments/__main__.py +62 -0
- hamilton/plugins/h_experiments/cache.py +39 -0
- hamilton/plugins/h_experiments/data_model.py +68 -0
- hamilton/plugins/h_experiments/hook.py +219 -0
- hamilton/plugins/h_experiments/server.py +375 -0
- hamilton/plugins/h_kedro.py +152 -0
- hamilton/plugins/h_logging.py +454 -0
- hamilton/plugins/h_mcp/__init__.py +28 -0
- hamilton/plugins/h_mcp/__main__.py +33 -0
- hamilton/plugins/h_mcp/_helpers.py +129 -0
- hamilton/plugins/h_mcp/_templates.py +417 -0
- hamilton/plugins/h_mcp/server.py +328 -0
- hamilton/plugins/h_mlflow.py +335 -0
- hamilton/plugins/h_narwhals.py +134 -0
- hamilton/plugins/h_openlineage.py +400 -0
- hamilton/plugins/h_opentelemetry.py +167 -0
- hamilton/plugins/h_pandas.py +257 -0
- hamilton/plugins/h_pandera.py +117 -0
- hamilton/plugins/h_polars.py +304 -0
- hamilton/plugins/h_polars_lazyframe.py +282 -0
- hamilton/plugins/h_pyarrow.py +56 -0
- hamilton/plugins/h_pydantic.py +127 -0
- hamilton/plugins/h_ray.py +242 -0
- hamilton/plugins/h_rich.py +142 -0
- hamilton/plugins/h_schema.py +493 -0
- hamilton/plugins/h_slack.py +100 -0
- hamilton/plugins/h_spark.py +1380 -0
- hamilton/plugins/h_threadpool.py +125 -0
- hamilton/plugins/h_tqdm.py +122 -0
- hamilton/plugins/h_vaex.py +129 -0
- hamilton/plugins/huggingface_extensions.py +236 -0
- hamilton/plugins/ibis_extensions.py +93 -0
- hamilton/plugins/jupyter_magic.py +622 -0
- hamilton/plugins/kedro_extensions.py +117 -0
- hamilton/plugins/lightgbm_extensions.py +99 -0
- hamilton/plugins/matplotlib_extensions.py +108 -0
- hamilton/plugins/mlflow_extensions.py +216 -0
- hamilton/plugins/numpy_extensions.py +105 -0
- hamilton/plugins/pandas_extensions.py +1763 -0
- hamilton/plugins/plotly_extensions.py +150 -0
- hamilton/plugins/polars_extensions.py +71 -0
- hamilton/plugins/polars_implementations.py +25 -0
- hamilton/plugins/polars_lazyframe_extensions.py +302 -0
- hamilton/plugins/polars_post_1_0_0_extensions.py +877 -0
- hamilton/plugins/polars_pre_1_0_0_extension.py +836 -0
- hamilton/plugins/pydantic_extensions.py +98 -0
- hamilton/plugins/pyspark_pandas_extensions.py +47 -0
- hamilton/plugins/sklearn_plot_extensions.py +129 -0
- hamilton/plugins/spark_extensions.py +105 -0
- hamilton/plugins/vaex_extensions.py +51 -0
- hamilton/plugins/xgboost_extensions.py +91 -0
- hamilton/plugins/yaml_extensions.py +89 -0
- hamilton/registry.py +254 -0
- hamilton/settings.py +18 -0
- hamilton/telemetry.py +50 -0
- hamilton/version.py +18 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
|
12
|
+
# software distributed under the License is distributed on an
|
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
# KIND, either express or implied. See the License for the
|
|
15
|
+
# specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
|
|
18
|
+
import dataclasses
|
|
19
|
+
import io
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import pathlib
|
|
23
|
+
import pickle
|
|
24
|
+
from collections.abc import Collection
|
|
25
|
+
from typing import Any
|
|
26
|
+
|
|
27
|
+
from hamilton.io.data_adapters import DataLoader, DataSaver
|
|
28
|
+
from hamilton.io.utils import get_file_metadata
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclasses.dataclass
|
|
32
|
+
class JSONDataLoader(DataLoader):
|
|
33
|
+
path: str
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def applicable_types(cls) -> Collection[type]:
|
|
37
|
+
return [dict, list]
|
|
38
|
+
|
|
39
|
+
def load_data(self, type_: type) -> tuple[dict, dict[str, Any]]:
|
|
40
|
+
with open(self.path, "r") as f:
|
|
41
|
+
return json.load(f), get_file_metadata(self.path)
|
|
42
|
+
|
|
43
|
+
@classmethod
|
|
44
|
+
def name(cls) -> str:
|
|
45
|
+
return "json"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclasses.dataclass
|
|
49
|
+
class JSONDataSaver(DataSaver):
|
|
50
|
+
path: str
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def applicable_types(cls) -> Collection[type]:
|
|
54
|
+
return [dict, list]
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def name(cls) -> str:
|
|
58
|
+
return "json"
|
|
59
|
+
|
|
60
|
+
def save_data(self, data: Any) -> dict[str, Any]:
|
|
61
|
+
with open(self.path, "w") as f:
|
|
62
|
+
json.dump(data, f)
|
|
63
|
+
return get_file_metadata(self.path)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclasses.dataclass
|
|
67
|
+
class RawFileDataLoader(DataLoader):
|
|
68
|
+
path: str
|
|
69
|
+
encoding: str = "utf-8"
|
|
70
|
+
|
|
71
|
+
def load_data(self, type_: type) -> tuple[str, dict[str, Any]]:
|
|
72
|
+
with open(self.path, "r", encoding=self.encoding) as f:
|
|
73
|
+
return f.read(), get_file_metadata(self.path)
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def applicable_types(cls) -> Collection[type]:
|
|
77
|
+
return [str]
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def name(cls) -> str:
|
|
81
|
+
return "file"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@dataclasses.dataclass
|
|
85
|
+
class RawFileDataSaver(DataSaver):
|
|
86
|
+
path: str
|
|
87
|
+
encoding: str = "utf-8"
|
|
88
|
+
|
|
89
|
+
@classmethod
|
|
90
|
+
def applicable_types(cls) -> Collection[type]:
|
|
91
|
+
return [str]
|
|
92
|
+
|
|
93
|
+
@classmethod
|
|
94
|
+
def name(cls) -> str:
|
|
95
|
+
return "file"
|
|
96
|
+
|
|
97
|
+
def save_data(self, data: Any) -> dict[str, Any]:
|
|
98
|
+
with open(self.path, "w", encoding=self.encoding) as f:
|
|
99
|
+
f.write(data)
|
|
100
|
+
return get_file_metadata(self.path)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@dataclasses.dataclass
|
|
104
|
+
class RawFileDataSaverBytes(DataSaver):
|
|
105
|
+
path: pathlib.Path | str
|
|
106
|
+
|
|
107
|
+
@classmethod
|
|
108
|
+
def applicable_types(cls) -> Collection[type]:
|
|
109
|
+
return [bytes, io.BytesIO]
|
|
110
|
+
|
|
111
|
+
@classmethod
|
|
112
|
+
def name(cls) -> str:
|
|
113
|
+
return "file"
|
|
114
|
+
|
|
115
|
+
def save_data(self, data: bytes | io.BytesIO) -> dict[str, Any]:
|
|
116
|
+
if isinstance(data, io.BytesIO):
|
|
117
|
+
data_bytes = data.getvalue() # Extract bytes from BytesIO
|
|
118
|
+
else:
|
|
119
|
+
data_bytes = data
|
|
120
|
+
|
|
121
|
+
with open(self.path, "wb") as file:
|
|
122
|
+
file.write(data_bytes)
|
|
123
|
+
|
|
124
|
+
return get_file_metadata(str(self.path))
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@dataclasses.dataclass
|
|
128
|
+
class PickleLoader(DataLoader):
|
|
129
|
+
path: str
|
|
130
|
+
|
|
131
|
+
@classmethod
|
|
132
|
+
def applicable_types(cls) -> Collection[type]:
|
|
133
|
+
return [object, Any]
|
|
134
|
+
|
|
135
|
+
@classmethod
|
|
136
|
+
def name(cls) -> str:
|
|
137
|
+
return "pickle"
|
|
138
|
+
|
|
139
|
+
def load_data(self, type_: type[object]) -> tuple[object, dict[str, Any]]:
|
|
140
|
+
with open(self.path, "rb") as f:
|
|
141
|
+
return pickle.load(f), get_file_metadata(self.path)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@dataclasses.dataclass
|
|
145
|
+
class PickleSaver(DataSaver):
|
|
146
|
+
path: str
|
|
147
|
+
|
|
148
|
+
@classmethod
|
|
149
|
+
def applicable_types(cls) -> Collection[type]:
|
|
150
|
+
return [object]
|
|
151
|
+
|
|
152
|
+
@classmethod
|
|
153
|
+
def name(cls) -> str:
|
|
154
|
+
return "pickle"
|
|
155
|
+
|
|
156
|
+
def save_data(self, data: Any) -> dict[str, Any]:
|
|
157
|
+
with open(self.path, "wb") as f:
|
|
158
|
+
pickle.dump(data, f)
|
|
159
|
+
return get_file_metadata(self.path)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
@dataclasses.dataclass
|
|
163
|
+
class EnvVarDataLoader(DataLoader):
|
|
164
|
+
names: tuple[str, ...]
|
|
165
|
+
|
|
166
|
+
def load_data(self, type_: type[dict]) -> tuple[dict, dict[str, Any]]:
|
|
167
|
+
return {name: os.environ[name] for name in self.names}, {}
|
|
168
|
+
|
|
169
|
+
@classmethod
|
|
170
|
+
def name(cls) -> str:
|
|
171
|
+
return "environment"
|
|
172
|
+
|
|
173
|
+
@classmethod
|
|
174
|
+
def applicable_types(cls) -> Collection[type]:
|
|
175
|
+
return [dict]
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
@dataclasses.dataclass
|
|
179
|
+
class LiteralValueDataLoader(DataLoader):
|
|
180
|
+
value: Any
|
|
181
|
+
|
|
182
|
+
@classmethod
|
|
183
|
+
def applicable_types(cls) -> Collection[type]:
|
|
184
|
+
return [Any]
|
|
185
|
+
|
|
186
|
+
def load_data(self, type_: type) -> tuple[dict, dict[str, Any]]:
|
|
187
|
+
return self.value, {}
|
|
188
|
+
|
|
189
|
+
@classmethod
|
|
190
|
+
def name(cls) -> str:
|
|
191
|
+
return "literal"
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
@dataclasses.dataclass
|
|
195
|
+
class InMemoryResult(DataSaver):
|
|
196
|
+
"""Class specifically to returning an in memory result without saving it anywhere.
|
|
197
|
+
|
|
198
|
+
Use this to get the result of a combiner easily; depends on their use.
|
|
199
|
+
"""
|
|
200
|
+
|
|
201
|
+
@classmethod
|
|
202
|
+
def applicable_types(cls) -> Collection[type]:
|
|
203
|
+
return [Any]
|
|
204
|
+
|
|
205
|
+
def save_data(self, data: Any) -> Any:
|
|
206
|
+
return data
|
|
207
|
+
|
|
208
|
+
@classmethod
|
|
209
|
+
def name(cls) -> str:
|
|
210
|
+
return "memory"
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
DATA_ADAPTERS = [
|
|
214
|
+
JSONDataSaver,
|
|
215
|
+
JSONDataLoader,
|
|
216
|
+
LiteralValueDataLoader,
|
|
217
|
+
RawFileDataLoader,
|
|
218
|
+
RawFileDataSaver,
|
|
219
|
+
RawFileDataSaverBytes,
|
|
220
|
+
PickleLoader,
|
|
221
|
+
PickleSaver,
|
|
222
|
+
EnvVarDataLoader,
|
|
223
|
+
InMemoryResult,
|
|
224
|
+
]
|