ob-metaflow 2.9.10.1__py2.py3-none-any.whl → 2.10.2.6__py2.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.

Potentially problematic release.


This version of ob-metaflow might be problematic. Click here for more details.

Files changed (57) hide show
  1. metaflow/_vendor/packaging/__init__.py +15 -0
  2. metaflow/_vendor/packaging/_elffile.py +108 -0
  3. metaflow/_vendor/packaging/_manylinux.py +238 -0
  4. metaflow/_vendor/packaging/_musllinux.py +80 -0
  5. metaflow/_vendor/packaging/_parser.py +328 -0
  6. metaflow/_vendor/packaging/_structures.py +61 -0
  7. metaflow/_vendor/packaging/_tokenizer.py +188 -0
  8. metaflow/_vendor/packaging/markers.py +245 -0
  9. metaflow/_vendor/packaging/requirements.py +95 -0
  10. metaflow/_vendor/packaging/specifiers.py +1005 -0
  11. metaflow/_vendor/packaging/tags.py +546 -0
  12. metaflow/_vendor/packaging/utils.py +141 -0
  13. metaflow/_vendor/packaging/version.py +563 -0
  14. metaflow/_vendor/v3_7/__init__.py +1 -0
  15. metaflow/_vendor/v3_7/zipp.py +329 -0
  16. metaflow/metaflow_config.py +2 -1
  17. metaflow/metaflow_environment.py +3 -1
  18. metaflow/mflog/mflog.py +7 -1
  19. metaflow/multicore_utils.py +12 -2
  20. metaflow/plugins/__init__.py +8 -3
  21. metaflow/plugins/airflow/airflow.py +13 -0
  22. metaflow/plugins/argo/argo_client.py +16 -0
  23. metaflow/plugins/argo/argo_events.py +7 -1
  24. metaflow/plugins/argo/argo_workflows.py +62 -0
  25. metaflow/plugins/argo/argo_workflows_cli.py +15 -0
  26. metaflow/plugins/aws/batch/batch.py +10 -0
  27. metaflow/plugins/aws/batch/batch_cli.py +1 -2
  28. metaflow/plugins/aws/batch/batch_decorator.py +2 -9
  29. metaflow/plugins/datatools/s3/s3.py +4 -0
  30. metaflow/plugins/env_escape/client.py +24 -3
  31. metaflow/plugins/env_escape/stub.py +2 -8
  32. metaflow/plugins/kubernetes/kubernetes.py +13 -0
  33. metaflow/plugins/kubernetes/kubernetes_cli.py +1 -2
  34. metaflow/plugins/kubernetes/kubernetes_decorator.py +9 -2
  35. metaflow/plugins/pypi/__init__.py +29 -0
  36. metaflow/plugins/pypi/bootstrap.py +131 -0
  37. metaflow/plugins/pypi/conda_decorator.py +335 -0
  38. metaflow/plugins/pypi/conda_environment.py +414 -0
  39. metaflow/plugins/pypi/micromamba.py +294 -0
  40. metaflow/plugins/pypi/pip.py +205 -0
  41. metaflow/plugins/pypi/pypi_decorator.py +130 -0
  42. metaflow/plugins/pypi/pypi_environment.py +7 -0
  43. metaflow/plugins/pypi/utils.py +75 -0
  44. metaflow/task.py +0 -3
  45. metaflow/vendor.py +1 -0
  46. {ob_metaflow-2.9.10.1.dist-info → ob_metaflow-2.10.2.6.dist-info}/METADATA +1 -1
  47. {ob_metaflow-2.9.10.1.dist-info → ob_metaflow-2.10.2.6.dist-info}/RECORD +51 -33
  48. {ob_metaflow-2.9.10.1.dist-info → ob_metaflow-2.10.2.6.dist-info}/WHEEL +1 -1
  49. metaflow/plugins/conda/__init__.py +0 -90
  50. metaflow/plugins/conda/batch_bootstrap.py +0 -104
  51. metaflow/plugins/conda/conda.py +0 -247
  52. metaflow/plugins/conda/conda_environment.py +0 -136
  53. metaflow/plugins/conda/conda_flow_decorator.py +0 -35
  54. metaflow/plugins/conda/conda_step_decorator.py +0 -416
  55. {ob_metaflow-2.9.10.1.dist-info → ob_metaflow-2.10.2.6.dist-info}/LICENSE +0 -0
  56. {ob_metaflow-2.9.10.1.dist-info → ob_metaflow-2.10.2.6.dist-info}/entry_points.txt +0 -0
  57. {ob_metaflow-2.9.10.1.dist-info → ob_metaflow-2.10.2.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,245 @@
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import operator
6
+ import os
7
+ import platform
8
+ import sys
9
+ from typing import Any, Callable, Dict, List, Optional, Tuple, Union
10
+
11
+ from ._parser import MarkerAtom, MarkerList, Op, Value, Variable, parse_marker
12
+ from ._tokenizer import ParserSyntaxError
13
+ from .specifiers import InvalidSpecifier, Specifier
14
+ from .utils import canonicalize_name
15
+
16
+ __all__ = [
17
+ "InvalidMarker",
18
+ "UndefinedComparison",
19
+ "UndefinedEnvironmentName",
20
+ "Marker",
21
+ "default_environment",
22
+ ]
23
+
24
+ Operator = Callable[[str, str], bool]
25
+
26
+
27
+ class InvalidMarker(ValueError):
28
+ """
29
+ An invalid marker was found, users should refer to PEP 508.
30
+ """
31
+
32
+
33
+ class UndefinedComparison(ValueError):
34
+ """
35
+ An invalid operation was attempted on a value that doesn't support it.
36
+ """
37
+
38
+
39
+ class UndefinedEnvironmentName(ValueError):
40
+ """
41
+ A name was attempted to be used that does not exist inside of the
42
+ environment.
43
+ """
44
+
45
+
46
+ def _normalize_extra_values(results: Any) -> Any:
47
+ """
48
+ Normalize extra values.
49
+ """
50
+ if isinstance(results[0], tuple):
51
+ lhs, op, rhs = results[0]
52
+ if isinstance(lhs, Variable) and lhs.value == "extra":
53
+ normalized_extra = canonicalize_name(rhs.value)
54
+ rhs = Value(normalized_extra)
55
+ elif isinstance(rhs, Variable) and rhs.value == "extra":
56
+ normalized_extra = canonicalize_name(lhs.value)
57
+ lhs = Value(normalized_extra)
58
+ results[0] = lhs, op, rhs
59
+ return results
60
+
61
+
62
+ def _format_marker(
63
+ marker: Union[List[str], MarkerAtom, str], first: Optional[bool] = True
64
+ ) -> str:
65
+
66
+ assert isinstance(marker, (list, tuple, str))
67
+
68
+ # Sometimes we have a structure like [[...]] which is a single item list
69
+ # where the single item is itself it's own list. In that case we want skip
70
+ # the rest of this function so that we don't get extraneous () on the
71
+ # outside.
72
+ if (
73
+ isinstance(marker, list)
74
+ and len(marker) == 1
75
+ and isinstance(marker[0], (list, tuple))
76
+ ):
77
+ return _format_marker(marker[0])
78
+
79
+ if isinstance(marker, list):
80
+ inner = (_format_marker(m, first=False) for m in marker)
81
+ if first:
82
+ return " ".join(inner)
83
+ else:
84
+ return "(" + " ".join(inner) + ")"
85
+ elif isinstance(marker, tuple):
86
+ return " ".join([m.serialize() for m in marker])
87
+ else:
88
+ return marker
89
+
90
+
91
+ _operators: Dict[str, Operator] = {
92
+ "in": lambda lhs, rhs: lhs in rhs,
93
+ "not in": lambda lhs, rhs: lhs not in rhs,
94
+ "<": operator.lt,
95
+ "<=": operator.le,
96
+ "==": operator.eq,
97
+ "!=": operator.ne,
98
+ ">=": operator.ge,
99
+ ">": operator.gt,
100
+ }
101
+
102
+
103
+ def _eval_op(lhs: str, op: Op, rhs: str) -> bool:
104
+ try:
105
+ spec = Specifier("".join([op.serialize(), rhs]))
106
+ except InvalidSpecifier:
107
+ pass
108
+ else:
109
+ return spec.contains(lhs, prereleases=True)
110
+
111
+ oper: Optional[Operator] = _operators.get(op.serialize())
112
+ if oper is None:
113
+ raise UndefinedComparison(f"Undefined {op!r} on {lhs!r} and {rhs!r}.")
114
+
115
+ return oper(lhs, rhs)
116
+
117
+
118
+ def _normalize(*values: str, key: str) -> Tuple[str, ...]:
119
+ # PEP 685 – Comparison of extra names for optional distribution dependencies
120
+ # https://peps.python.org/pep-0685/
121
+ # > When comparing extra names, tools MUST normalize the names being
122
+ # > compared using the semantics outlined in PEP 503 for names
123
+ if key == "extra":
124
+ return tuple(canonicalize_name(v) for v in values)
125
+
126
+ # other environment markers don't have such standards
127
+ return values
128
+
129
+
130
+ def _evaluate_markers(markers: MarkerList, environment: Dict[str, str]) -> bool:
131
+ groups: List[List[bool]] = [[]]
132
+
133
+ for marker in markers:
134
+ assert isinstance(marker, (list, tuple, str))
135
+
136
+ if isinstance(marker, list):
137
+ groups[-1].append(_evaluate_markers(marker, environment))
138
+ elif isinstance(marker, tuple):
139
+ lhs, op, rhs = marker
140
+
141
+ if isinstance(lhs, Variable):
142
+ environment_key = lhs.value
143
+ lhs_value = environment[environment_key]
144
+ rhs_value = rhs.value
145
+ else:
146
+ lhs_value = lhs.value
147
+ environment_key = rhs.value
148
+ rhs_value = environment[environment_key]
149
+
150
+ lhs_value, rhs_value = _normalize(lhs_value, rhs_value, key=environment_key)
151
+ groups[-1].append(_eval_op(lhs_value, op, rhs_value))
152
+ else:
153
+ assert marker in ["and", "or"]
154
+ if marker == "or":
155
+ groups.append([])
156
+
157
+ return any(all(item) for item in groups)
158
+
159
+
160
+ def format_full_version(info: "sys._version_info") -> str:
161
+ version = "{0.major}.{0.minor}.{0.micro}".format(info)
162
+ kind = info.releaselevel
163
+ if kind != "final":
164
+ version += kind[0] + str(info.serial)
165
+ return version
166
+
167
+
168
+ def default_environment() -> Dict[str, str]:
169
+ iver = format_full_version(sys.implementation.version)
170
+ implementation_name = sys.implementation.name
171
+ return {
172
+ "implementation_name": implementation_name,
173
+ "implementation_version": iver,
174
+ "os_name": os.name,
175
+ "platform_machine": platform.machine(),
176
+ "platform_release": platform.release(),
177
+ "platform_system": platform.system(),
178
+ "platform_version": platform.version(),
179
+ "python_full_version": platform.python_version(),
180
+ "platform_python_implementation": platform.python_implementation(),
181
+ "python_version": ".".join(platform.python_version_tuple()[:2]),
182
+ "sys_platform": sys.platform,
183
+ }
184
+
185
+
186
+ class Marker:
187
+ def __init__(self, marker: str) -> None:
188
+ # Note: We create a Marker object without calling this constructor in
189
+ # packaging.requirements.Requirement. If any additional logic is
190
+ # added here, make sure to mirror/adapt Requirement.
191
+ try:
192
+ self._markers = _normalize_extra_values(parse_marker(marker))
193
+ # The attribute `_markers` can be described in terms of a recursive type:
194
+ # MarkerList = List[Union[Tuple[Node, ...], str, MarkerList]]
195
+ #
196
+ # For example, the following expression:
197
+ # python_version > "3.6" or (python_version == "3.6" and os_name == "unix")
198
+ #
199
+ # is parsed into:
200
+ # [
201
+ # (<Variable('python_version')>, <Op('>')>, <Value('3.6')>),
202
+ # 'and',
203
+ # [
204
+ # (<Variable('python_version')>, <Op('==')>, <Value('3.6')>),
205
+ # 'or',
206
+ # (<Variable('os_name')>, <Op('==')>, <Value('unix')>)
207
+ # ]
208
+ # ]
209
+ except ParserSyntaxError as e:
210
+ raise InvalidMarker(str(e)) from e
211
+
212
+ def __str__(self) -> str:
213
+ return _format_marker(self._markers)
214
+
215
+ def __repr__(self) -> str:
216
+ return f"<Marker('{self}')>"
217
+
218
+ def __hash__(self) -> int:
219
+ return hash((self.__class__.__name__, str(self)))
220
+
221
+ def __eq__(self, other: Any) -> bool:
222
+ if not isinstance(other, Marker):
223
+ return NotImplemented
224
+
225
+ return str(self) == str(other)
226
+
227
+ def evaluate(self, environment: Optional[Dict[str, str]] = None) -> bool:
228
+ """Evaluate a marker.
229
+
230
+ Return the boolean from evaluating the given marker against the
231
+ environment. environment is an optional argument to override all or
232
+ part of the determined environment.
233
+
234
+ The environment is determined from the current Python process.
235
+ """
236
+ current_environment = default_environment()
237
+ current_environment["extra"] = ""
238
+ if environment is not None:
239
+ current_environment.update(environment)
240
+ # The API used to allow setting extra to None. We need to handle this
241
+ # case for backwards compatibility.
242
+ if current_environment["extra"] is None:
243
+ current_environment["extra"] = ""
244
+
245
+ return _evaluate_markers(self._markers, current_environment)
@@ -0,0 +1,95 @@
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import urllib.parse
6
+ from typing import Any, List, Optional, Set
7
+
8
+ from ._parser import parse_requirement
9
+ from ._tokenizer import ParserSyntaxError
10
+ from .markers import Marker, _normalize_extra_values
11
+ from .specifiers import SpecifierSet
12
+
13
+
14
+ class InvalidRequirement(ValueError):
15
+ """
16
+ An invalid requirement was found, users should refer to PEP 508.
17
+ """
18
+
19
+
20
+ class Requirement:
21
+ """Parse a requirement.
22
+
23
+ Parse a given requirement string into its parts, such as name, specifier,
24
+ URL, and extras. Raises InvalidRequirement on a badly-formed requirement
25
+ string.
26
+ """
27
+
28
+ # TODO: Can we test whether something is contained within a requirement?
29
+ # If so how do we do that? Do we need to test against the _name_ of
30
+ # the thing as well as the version? What about the markers?
31
+ # TODO: Can we normalize the name and extra name?
32
+
33
+ def __init__(self, requirement_string: str) -> None:
34
+ try:
35
+ parsed = parse_requirement(requirement_string)
36
+ except ParserSyntaxError as e:
37
+ raise InvalidRequirement(str(e)) from e
38
+
39
+ self.name: str = parsed.name
40
+ if parsed.url:
41
+ parsed_url = urllib.parse.urlparse(parsed.url)
42
+ if parsed_url.scheme == "file":
43
+ if urllib.parse.urlunparse(parsed_url) != parsed.url:
44
+ raise InvalidRequirement("Invalid URL given")
45
+ elif not (parsed_url.scheme and parsed_url.netloc) or (
46
+ not parsed_url.scheme and not parsed_url.netloc
47
+ ):
48
+ raise InvalidRequirement(f"Invalid URL: {parsed.url}")
49
+ self.url: Optional[str] = parsed.url
50
+ else:
51
+ self.url = None
52
+ self.extras: Set[str] = set(parsed.extras if parsed.extras else [])
53
+ self.specifier: SpecifierSet = SpecifierSet(parsed.specifier)
54
+ self.marker: Optional[Marker] = None
55
+ if parsed.marker is not None:
56
+ self.marker = Marker.__new__(Marker)
57
+ self.marker._markers = _normalize_extra_values(parsed.marker)
58
+
59
+ def __str__(self) -> str:
60
+ parts: List[str] = [self.name]
61
+
62
+ if self.extras:
63
+ formatted_extras = ",".join(sorted(self.extras))
64
+ parts.append(f"[{formatted_extras}]")
65
+
66
+ if self.specifier:
67
+ parts.append(str(self.specifier))
68
+
69
+ if self.url:
70
+ parts.append(f"@ {self.url}")
71
+ if self.marker:
72
+ parts.append(" ")
73
+
74
+ if self.marker:
75
+ parts.append(f"; {self.marker}")
76
+
77
+ return "".join(parts)
78
+
79
+ def __repr__(self) -> str:
80
+ return f"<Requirement('{self}')>"
81
+
82
+ def __hash__(self) -> int:
83
+ return hash((self.__class__.__name__, str(self)))
84
+
85
+ def __eq__(self, other: Any) -> bool:
86
+ if not isinstance(other, Requirement):
87
+ return NotImplemented
88
+
89
+ return (
90
+ self.name == other.name
91
+ and self.extras == other.extras
92
+ and self.specifier == other.specifier
93
+ and self.url == other.url
94
+ and self.marker == other.marker
95
+ )