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.
Files changed (151) hide show
  1. apache_hamilton-1.90.0.dev0.dist-info/METADATA +407 -0
  2. apache_hamilton-1.90.0.dev0.dist-info/RECORD +151 -0
  3. apache_hamilton-1.90.0.dev0.dist-info/WHEEL +4 -0
  4. apache_hamilton-1.90.0.dev0.dist-info/entry_points.txt +9 -0
  5. apache_hamilton-1.90.0.dev0.dist-info/licenses/DISCLAIMER +10 -0
  6. apache_hamilton-1.90.0.dev0.dist-info/licenses/LICENSE +228 -0
  7. apache_hamilton-1.90.0.dev0.dist-info/licenses/NOTICE +5 -0
  8. hamilton/__init__.py +24 -0
  9. hamilton/ad_hoc_utils.py +132 -0
  10. hamilton/async_driver.py +465 -0
  11. hamilton/base.py +466 -0
  12. hamilton/caching/__init__.py +16 -0
  13. hamilton/caching/adapter.py +1475 -0
  14. hamilton/caching/cache_key.py +70 -0
  15. hamilton/caching/fingerprinting.py +287 -0
  16. hamilton/caching/stores/__init__.py +16 -0
  17. hamilton/caching/stores/base.py +242 -0
  18. hamilton/caching/stores/file.py +140 -0
  19. hamilton/caching/stores/memory.py +297 -0
  20. hamilton/caching/stores/sqlite.py +282 -0
  21. hamilton/caching/stores/utils.py +40 -0
  22. hamilton/cli/__init__.py +16 -0
  23. hamilton/cli/__main__.py +328 -0
  24. hamilton/cli/commands.py +126 -0
  25. hamilton/cli/logic.py +338 -0
  26. hamilton/common/__init__.py +76 -0
  27. hamilton/contrib/__init__.py +41 -0
  28. hamilton/data_quality/__init__.py +16 -0
  29. hamilton/data_quality/base.py +198 -0
  30. hamilton/data_quality/default_validators.py +560 -0
  31. hamilton/data_quality/pandera_validators.py +121 -0
  32. hamilton/dataflows/__init__.py +726 -0
  33. hamilton/dataflows/template/README.md +25 -0
  34. hamilton/dataflows/template/__init__.py +54 -0
  35. hamilton/dataflows/template/author.md +28 -0
  36. hamilton/dataflows/template/requirements.txt +0 -0
  37. hamilton/dataflows/template/tags.json +7 -0
  38. hamilton/dataflows/template/valid_configs.jsonl +1 -0
  39. hamilton/dev_utils/__init__.py +16 -0
  40. hamilton/dev_utils/deprecation.py +204 -0
  41. hamilton/driver.py +2112 -0
  42. hamilton/execution/__init__.py +16 -0
  43. hamilton/execution/debugging_utils.py +56 -0
  44. hamilton/execution/executors.py +502 -0
  45. hamilton/execution/graph_functions.py +421 -0
  46. hamilton/execution/grouping.py +430 -0
  47. hamilton/execution/state.py +539 -0
  48. hamilton/experimental/__init__.py +27 -0
  49. hamilton/experimental/databackend.py +61 -0
  50. hamilton/experimental/decorators/__init__.py +16 -0
  51. hamilton/experimental/decorators/parameterize_frame.py +233 -0
  52. hamilton/experimental/h_async.py +29 -0
  53. hamilton/experimental/h_cache.py +413 -0
  54. hamilton/experimental/h_dask.py +28 -0
  55. hamilton/experimental/h_databackends.py +174 -0
  56. hamilton/experimental/h_ray.py +28 -0
  57. hamilton/experimental/h_spark.py +32 -0
  58. hamilton/function_modifiers/README +40 -0
  59. hamilton/function_modifiers/__init__.py +121 -0
  60. hamilton/function_modifiers/adapters.py +900 -0
  61. hamilton/function_modifiers/base.py +859 -0
  62. hamilton/function_modifiers/configuration.py +310 -0
  63. hamilton/function_modifiers/delayed.py +202 -0
  64. hamilton/function_modifiers/dependencies.py +246 -0
  65. hamilton/function_modifiers/expanders.py +1230 -0
  66. hamilton/function_modifiers/macros.py +1634 -0
  67. hamilton/function_modifiers/metadata.py +434 -0
  68. hamilton/function_modifiers/recursive.py +908 -0
  69. hamilton/function_modifiers/validation.py +289 -0
  70. hamilton/function_modifiers_base.py +31 -0
  71. hamilton/graph.py +1153 -0
  72. hamilton/graph_types.py +264 -0
  73. hamilton/graph_utils.py +41 -0
  74. hamilton/htypes.py +450 -0
  75. hamilton/io/__init__.py +32 -0
  76. hamilton/io/data_adapters.py +216 -0
  77. hamilton/io/default_data_loaders.py +224 -0
  78. hamilton/io/materialization.py +500 -0
  79. hamilton/io/utils.py +158 -0
  80. hamilton/lifecycle/__init__.py +67 -0
  81. hamilton/lifecycle/api.py +833 -0
  82. hamilton/lifecycle/base.py +1130 -0
  83. hamilton/lifecycle/default.py +802 -0
  84. hamilton/log_setup.py +47 -0
  85. hamilton/models.py +92 -0
  86. hamilton/node.py +449 -0
  87. hamilton/plugins/README.md +48 -0
  88. hamilton/plugins/__init__.py +16 -0
  89. hamilton/plugins/dask_extensions.py +47 -0
  90. hamilton/plugins/dlt_extensions.py +161 -0
  91. hamilton/plugins/geopandas_extensions.py +49 -0
  92. hamilton/plugins/h_dask.py +331 -0
  93. hamilton/plugins/h_ddog.py +522 -0
  94. hamilton/plugins/h_diskcache.py +163 -0
  95. hamilton/plugins/h_experiments/__init__.py +22 -0
  96. hamilton/plugins/h_experiments/__main__.py +62 -0
  97. hamilton/plugins/h_experiments/cache.py +39 -0
  98. hamilton/plugins/h_experiments/data_model.py +68 -0
  99. hamilton/plugins/h_experiments/hook.py +219 -0
  100. hamilton/plugins/h_experiments/server.py +375 -0
  101. hamilton/plugins/h_kedro.py +152 -0
  102. hamilton/plugins/h_logging.py +454 -0
  103. hamilton/plugins/h_mcp/__init__.py +28 -0
  104. hamilton/plugins/h_mcp/__main__.py +33 -0
  105. hamilton/plugins/h_mcp/_helpers.py +129 -0
  106. hamilton/plugins/h_mcp/_templates.py +417 -0
  107. hamilton/plugins/h_mcp/server.py +328 -0
  108. hamilton/plugins/h_mlflow.py +335 -0
  109. hamilton/plugins/h_narwhals.py +134 -0
  110. hamilton/plugins/h_openlineage.py +400 -0
  111. hamilton/plugins/h_opentelemetry.py +167 -0
  112. hamilton/plugins/h_pandas.py +257 -0
  113. hamilton/plugins/h_pandera.py +117 -0
  114. hamilton/plugins/h_polars.py +304 -0
  115. hamilton/plugins/h_polars_lazyframe.py +282 -0
  116. hamilton/plugins/h_pyarrow.py +56 -0
  117. hamilton/plugins/h_pydantic.py +127 -0
  118. hamilton/plugins/h_ray.py +242 -0
  119. hamilton/plugins/h_rich.py +142 -0
  120. hamilton/plugins/h_schema.py +493 -0
  121. hamilton/plugins/h_slack.py +100 -0
  122. hamilton/plugins/h_spark.py +1380 -0
  123. hamilton/plugins/h_threadpool.py +125 -0
  124. hamilton/plugins/h_tqdm.py +122 -0
  125. hamilton/plugins/h_vaex.py +129 -0
  126. hamilton/plugins/huggingface_extensions.py +236 -0
  127. hamilton/plugins/ibis_extensions.py +93 -0
  128. hamilton/plugins/jupyter_magic.py +622 -0
  129. hamilton/plugins/kedro_extensions.py +117 -0
  130. hamilton/plugins/lightgbm_extensions.py +99 -0
  131. hamilton/plugins/matplotlib_extensions.py +108 -0
  132. hamilton/plugins/mlflow_extensions.py +216 -0
  133. hamilton/plugins/numpy_extensions.py +105 -0
  134. hamilton/plugins/pandas_extensions.py +1763 -0
  135. hamilton/plugins/plotly_extensions.py +150 -0
  136. hamilton/plugins/polars_extensions.py +71 -0
  137. hamilton/plugins/polars_implementations.py +25 -0
  138. hamilton/plugins/polars_lazyframe_extensions.py +302 -0
  139. hamilton/plugins/polars_post_1_0_0_extensions.py +877 -0
  140. hamilton/plugins/polars_pre_1_0_0_extension.py +836 -0
  141. hamilton/plugins/pydantic_extensions.py +98 -0
  142. hamilton/plugins/pyspark_pandas_extensions.py +47 -0
  143. hamilton/plugins/sklearn_plot_extensions.py +129 -0
  144. hamilton/plugins/spark_extensions.py +105 -0
  145. hamilton/plugins/vaex_extensions.py +51 -0
  146. hamilton/plugins/xgboost_extensions.py +91 -0
  147. hamilton/plugins/yaml_extensions.py +89 -0
  148. hamilton/registry.py +254 -0
  149. hamilton/settings.py +18 -0
  150. hamilton/telemetry.py +50 -0
  151. hamilton/version.py +18 -0
@@ -0,0 +1,25 @@
1
+ <!--
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ -->
19
+ # Purpose of this module
20
+
21
+
22
+ # Configuration Options
23
+ This module can be configured with the following options:
24
+
25
+ # Limitations
@@ -0,0 +1,54 @@
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
+ # --- START LICENSE (optional)
19
+ # --- END LICENSE
20
+ # --- START IMPORT SECTION
21
+ import logging
22
+
23
+ from hamilton import contrib
24
+
25
+ logger = logging.getLogger(__name__)
26
+
27
+ with contrib.catch_import_errors(__name__, __file__, logger):
28
+ # non-hamilton imports go here
29
+ pass
30
+
31
+ # hamilton imports go here; check for required version if need be.
32
+
33
+ # --- END IMPORT SECTION
34
+
35
+ # --- START HAMILTON DATAFLOW
36
+
37
+
38
+ # --- END HAMILTON DATAFLOW
39
+ # --- START MAIN CODE
40
+ if __name__ == "__main__":
41
+ # Code to create an imaging showing on DAG workflow.
42
+ # run as a script to test Hamilton's execution
43
+ import __init__ as MODULE_NAME
44
+
45
+ from hamilton import base, driver
46
+
47
+ dr = driver.Driver(
48
+ {}, # CONFIG: fill as appropriate
49
+ MODULE_NAME,
50
+ adapter=base.DefaultAdapter(),
51
+ )
52
+ # saves to current working directory creating dag.png.
53
+ dr.display_all_functions("dag", {"format": "png", "view": False})
54
+ # --- END MAIN CODE
@@ -0,0 +1,28 @@
1
+ <!--
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ -->
19
+
20
+ # {github_username}
21
+
22
+ Hi I'm ...
23
+
24
+ # Github
25
+ https://github.com/{github_username}
26
+ # Linkedin
27
+
28
+ # X (Twitter)
File without changes
@@ -0,0 +1,7 @@
1
+ {
2
+ "schema": "1.0",
3
+ "use_case_tags": [],
4
+ "secondary_tags": {
5
+ "language": "English"
6
+ }
7
+ }
@@ -0,0 +1,16 @@
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.
@@ -0,0 +1,204 @@
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 functools
20
+ import logging
21
+ import types
22
+ from collections.abc import Callable
23
+
24
+ from hamilton import version
25
+
26
+ logger = logging.getLogger(__name__)
27
+
28
+
29
+ @dataclasses.dataclass
30
+ class Version:
31
+ major: int
32
+ minor: int
33
+ patch: int
34
+
35
+ def __gt__(self, other: "Version"):
36
+ return (self.major, self.minor, self.patch) > (other.major, other.minor, other.patch)
37
+
38
+ @staticmethod
39
+ def from_version_tuple(version_tuple: tuple[int | str, ...]) -> "Version":
40
+ version_ = version_tuple
41
+ if len(version_) > 3: # This means we have an RC
42
+ version_ = version_tuple[0:3] # Then let's ignore it
43
+ return Version(*version_) # TODO, add some validation
44
+
45
+ @staticmethod
46
+ def current() -> "Version":
47
+ current_version = version.VERSION
48
+ return Version.from_version_tuple(current_version)
49
+
50
+ def __repr__(self):
51
+ return ".".join(map(str, [self.major, self.minor, self.patch]))
52
+
53
+
54
+ CURRENT_VERSION = Version.current()
55
+
56
+
57
+ class DeprecationError(Exception):
58
+ def raise_(self):
59
+ raise self
60
+
61
+
62
+ @dataclasses.dataclass
63
+ class deprecated:
64
+ """Deprecation decorator -- use judiciously! For example:
65
+ @deprecate(
66
+ warn_starting=(1,10,0)
67
+ fail_starting=(2,0,0),
68
+ use_this=parameterize_values,
69
+ explanation='We have redefined the parameterization decorators to consist of `parametrize`, `parametrize_inputs`, and `parametrize_values`
70
+ migration_guide="https://github.com/apache/hamilton/..."
71
+ )
72
+ class parameterized(...):
73
+ ...
74
+ Note this locks into a future contract (although it *can* be changed), so if you promise to deprecate something by X.0, then do it!
75
+
76
+ """
77
+
78
+ warn_starting: tuple[int, int, int] | Version
79
+ fail_starting: tuple[int, int, int] | Version
80
+ use_this: (
81
+ Callable | None
82
+ ) # If this is None, it means this functionality is no longer supported.
83
+ explanation: str
84
+ migration_guide: (
85
+ str | None
86
+ ) # If this is None, this means that the use_this is a drop in replacement
87
+ current_version: tuple[int, int, int] | Version = dataclasses.field(
88
+ default_factory=lambda: CURRENT_VERSION
89
+ )
90
+ warn_action: Callable[[str], None] = dataclasses.field(default=logger.warning)
91
+ fail_action: Callable[[str], None] = dataclasses.field(
92
+ default=lambda message: DeprecationError(message).raise_()
93
+ )
94
+
95
+ @staticmethod
96
+ def _raise_failure(message: str):
97
+ raise DeprecationError(message)
98
+
99
+ @staticmethod
100
+ def _ensure_version_type(version_spec: tuple[int, int, int] | Version) -> Version:
101
+ if isinstance(version_spec, tuple):
102
+ return Version(*version_spec)
103
+ return version_spec
104
+
105
+ def __post_init__(self):
106
+ if self.use_this is None:
107
+ if self.migration_guide is None:
108
+ raise ValueError(
109
+ "@deprecate must include a migration guide if there is no replacement."
110
+ )
111
+ self.warn_starting = deprecated._ensure_version_type(self.warn_starting)
112
+ self.fail_starting = deprecated._ensure_version_type(self.fail_starting)
113
+ self.current_version = deprecated._ensure_version_type(self.current_version)
114
+ self._validate_fail_starting()
115
+
116
+ def _validate_fail_starting(self):
117
+ if self.fail_starting.major > 0: # This means we're past alpha. We are, but nice to have...
118
+ if self.fail_starting.minor != 0 or self.fail_starting.patch != 0:
119
+ raise ValueError(
120
+ f"Can only deprecate starting on major version releases. {self.fail_starting} is not valid."
121
+ )
122
+ if self.warn_starting > self.fail_starting:
123
+ raise ValueError(
124
+ f"warn_starting must come before fail_starting. {self.fail_starting} < {self.warn_starting}"
125
+ )
126
+
127
+ def _do_deprecation_action(self, fn: Callable):
128
+ if self._should_fail():
129
+ failure_message = " ".join(
130
+ [
131
+ f"{fn.__qualname__} has been deprecated, as of hamilton version: {self.fail_starting}.",
132
+ f"{self.explanation}",
133
+ ]
134
+ + (
135
+ [f"Instead, you should be using: {self.use_this.__qualname__}."]
136
+ if self.use_this is not None
137
+ else []
138
+ )
139
+ + (
140
+ [f"For migration, see: {self.migration_guide}."]
141
+ if self.migration_guide is not None
142
+ else ["This is a drop-in replacement."]
143
+ )
144
+ )
145
+ self.fail_action(failure_message)
146
+ elif self._should_warn():
147
+ warn_message = " ".join(
148
+ [
149
+ f"{fn.__qualname__} will be deprecated by hamilton version: {self.fail_starting}.",
150
+ f"{self.explanation}",
151
+ ]
152
+ + (
153
+ [f"Instead, you should be using: {self.use_this.__qualname__}."]
154
+ if self.use_this is not None
155
+ else []
156
+ )
157
+ + (
158
+ [f"For migration, see: {self.migration_guide}."]
159
+ if self.migration_guide is not None
160
+ else ["This is a drop-in replacement."]
161
+ )
162
+ )
163
+ self.warn_action(warn_message)
164
+
165
+ def _should_warn(self) -> bool:
166
+ return self.current_version > self.warn_starting
167
+
168
+ def _should_fail(self) -> bool:
169
+ return self.current_version > self.fail_starting
170
+
171
+ def __call__(self, fn: Callable):
172
+ """Decorates the function with the deprecated decorator.
173
+ Note that this has different implementations for functions and
174
+ objects that masquerade as functions (E.G. by implementing __call__.
175
+
176
+ TODO -- use @singledispatchmethod -- this was written before that was available
177
+ https://docs.python.org/3/library/functools.html#functools.singledispatchmethod
178
+
179
+ :param fn: function (or class) to decorate
180
+ :return: The decorated function.
181
+ """
182
+ # In this case we just do a standard decorator
183
+ if isinstance(fn, types.FunctionType):
184
+
185
+ @functools.wraps(fn)
186
+ def new_fn(*args, **kwargs):
187
+ self._do_deprecation_action(fn)
188
+ return fn(*args, **kwargs)
189
+
190
+ return new_fn
191
+
192
+ # Otherwise we assume that this is a class object
193
+ # We have to store the former __call__
194
+ fn.__old_call__ = fn.__call__
195
+
196
+ def new__call__(self, *args, deprecator=self, fn=fn, **kwargs):
197
+ deprecator._do_deprecation_action(fn)
198
+ return fn.__old_call__(self, *args, **kwargs)
199
+
200
+ # This works as we're assigning it to the entire class...
201
+ # This also means we can't decorate it with 2 deprecation functions, but, hey,
202
+ # its on you if you try to deprecate something twice
203
+ fn.__call__ = new__call__
204
+ return fn