ob-metaflow 2.11.13.1__py2.py3-none-any.whl → 2.19.7.1rc0__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.
- metaflow/R.py +10 -7
- metaflow/__init__.py +40 -25
- metaflow/_vendor/imghdr/__init__.py +186 -0
- metaflow/_vendor/importlib_metadata/__init__.py +1063 -0
- metaflow/_vendor/importlib_metadata/_adapters.py +68 -0
- metaflow/_vendor/importlib_metadata/_collections.py +30 -0
- metaflow/_vendor/importlib_metadata/_compat.py +71 -0
- metaflow/_vendor/importlib_metadata/_functools.py +104 -0
- metaflow/_vendor/importlib_metadata/_itertools.py +73 -0
- metaflow/_vendor/importlib_metadata/_meta.py +48 -0
- metaflow/_vendor/importlib_metadata/_text.py +99 -0
- metaflow/_vendor/importlib_metadata/py.typed +0 -0
- metaflow/_vendor/typeguard/__init__.py +48 -0
- metaflow/_vendor/typeguard/_checkers.py +1070 -0
- metaflow/_vendor/typeguard/_config.py +108 -0
- metaflow/_vendor/typeguard/_decorators.py +233 -0
- metaflow/_vendor/typeguard/_exceptions.py +42 -0
- metaflow/_vendor/typeguard/_functions.py +308 -0
- metaflow/_vendor/typeguard/_importhook.py +213 -0
- metaflow/_vendor/typeguard/_memo.py +48 -0
- metaflow/_vendor/typeguard/_pytest_plugin.py +127 -0
- metaflow/_vendor/typeguard/_suppression.py +86 -0
- metaflow/_vendor/typeguard/_transformer.py +1229 -0
- metaflow/_vendor/typeguard/_union_transformer.py +55 -0
- metaflow/_vendor/typeguard/_utils.py +173 -0
- metaflow/_vendor/typeguard/py.typed +0 -0
- metaflow/_vendor/typing_extensions.py +3641 -0
- metaflow/_vendor/v3_7/importlib_metadata/__init__.py +1063 -0
- metaflow/_vendor/v3_7/importlib_metadata/_adapters.py +68 -0
- metaflow/_vendor/v3_7/importlib_metadata/_collections.py +30 -0
- metaflow/_vendor/v3_7/importlib_metadata/_compat.py +71 -0
- metaflow/_vendor/v3_7/importlib_metadata/_functools.py +104 -0
- metaflow/_vendor/v3_7/importlib_metadata/_itertools.py +73 -0
- metaflow/_vendor/v3_7/importlib_metadata/_meta.py +48 -0
- metaflow/_vendor/v3_7/importlib_metadata/_text.py +99 -0
- metaflow/_vendor/v3_7/importlib_metadata/py.typed +0 -0
- metaflow/_vendor/v3_7/typeguard/__init__.py +48 -0
- metaflow/_vendor/v3_7/typeguard/_checkers.py +906 -0
- metaflow/_vendor/v3_7/typeguard/_config.py +108 -0
- metaflow/_vendor/v3_7/typeguard/_decorators.py +237 -0
- metaflow/_vendor/v3_7/typeguard/_exceptions.py +42 -0
- metaflow/_vendor/v3_7/typeguard/_functions.py +310 -0
- metaflow/_vendor/v3_7/typeguard/_importhook.py +213 -0
- metaflow/_vendor/v3_7/typeguard/_memo.py +48 -0
- metaflow/_vendor/v3_7/typeguard/_pytest_plugin.py +100 -0
- metaflow/_vendor/v3_7/typeguard/_suppression.py +88 -0
- metaflow/_vendor/v3_7/typeguard/_transformer.py +1207 -0
- metaflow/_vendor/v3_7/typeguard/_union_transformer.py +54 -0
- metaflow/_vendor/v3_7/typeguard/_utils.py +169 -0
- metaflow/_vendor/v3_7/typeguard/py.typed +0 -0
- metaflow/_vendor/v3_7/typing_extensions.py +3072 -0
- metaflow/_vendor/yaml/__init__.py +427 -0
- metaflow/_vendor/yaml/composer.py +139 -0
- metaflow/_vendor/yaml/constructor.py +748 -0
- metaflow/_vendor/yaml/cyaml.py +101 -0
- metaflow/_vendor/yaml/dumper.py +62 -0
- metaflow/_vendor/yaml/emitter.py +1137 -0
- metaflow/_vendor/yaml/error.py +75 -0
- metaflow/_vendor/yaml/events.py +86 -0
- metaflow/_vendor/yaml/loader.py +63 -0
- metaflow/_vendor/yaml/nodes.py +49 -0
- metaflow/_vendor/yaml/parser.py +589 -0
- metaflow/_vendor/yaml/reader.py +185 -0
- metaflow/_vendor/yaml/representer.py +389 -0
- metaflow/_vendor/yaml/resolver.py +227 -0
- metaflow/_vendor/yaml/scanner.py +1435 -0
- metaflow/_vendor/yaml/serializer.py +111 -0
- metaflow/_vendor/yaml/tokens.py +104 -0
- metaflow/cards.py +5 -0
- metaflow/cli.py +331 -785
- metaflow/cli_args.py +17 -0
- metaflow/cli_components/__init__.py +0 -0
- metaflow/cli_components/dump_cmd.py +96 -0
- metaflow/cli_components/init_cmd.py +52 -0
- metaflow/cli_components/run_cmds.py +546 -0
- metaflow/cli_components/step_cmd.py +334 -0
- metaflow/cli_components/utils.py +140 -0
- metaflow/client/__init__.py +1 -0
- metaflow/client/core.py +467 -73
- metaflow/client/filecache.py +75 -35
- metaflow/clone_util.py +7 -1
- metaflow/cmd/code/__init__.py +231 -0
- metaflow/cmd/develop/stub_generator.py +756 -288
- metaflow/cmd/develop/stubs.py +12 -28
- metaflow/cmd/main_cli.py +6 -4
- metaflow/cmd/make_wrapper.py +78 -0
- metaflow/datastore/__init__.py +1 -0
- metaflow/datastore/content_addressed_store.py +41 -10
- metaflow/datastore/datastore_set.py +11 -2
- metaflow/datastore/flow_datastore.py +156 -10
- metaflow/datastore/spin_datastore.py +91 -0
- metaflow/datastore/task_datastore.py +154 -39
- metaflow/debug.py +5 -0
- metaflow/decorators.py +404 -78
- metaflow/exception.py +8 -2
- metaflow/extension_support/__init__.py +527 -376
- metaflow/extension_support/_empty_file.py +2 -2
- metaflow/extension_support/plugins.py +49 -31
- metaflow/flowspec.py +482 -33
- metaflow/graph.py +210 -42
- metaflow/includefile.py +84 -40
- metaflow/lint.py +141 -22
- metaflow/meta_files.py +13 -0
- metaflow/{metadata → metadata_provider}/heartbeat.py +24 -8
- metaflow/{metadata → metadata_provider}/metadata.py +86 -1
- metaflow/metaflow_config.py +175 -28
- metaflow/metaflow_config_funcs.py +51 -3
- metaflow/metaflow_current.py +4 -10
- metaflow/metaflow_environment.py +139 -53
- metaflow/metaflow_git.py +115 -0
- metaflow/metaflow_profile.py +18 -0
- metaflow/metaflow_version.py +150 -66
- metaflow/mflog/__init__.py +4 -3
- metaflow/mflog/save_logs.py +2 -2
- metaflow/multicore_utils.py +31 -14
- metaflow/package/__init__.py +673 -0
- metaflow/packaging_sys/__init__.py +880 -0
- metaflow/packaging_sys/backend.py +128 -0
- metaflow/packaging_sys/distribution_support.py +153 -0
- metaflow/packaging_sys/tar_backend.py +99 -0
- metaflow/packaging_sys/utils.py +54 -0
- metaflow/packaging_sys/v1.py +527 -0
- metaflow/parameters.py +149 -28
- metaflow/plugins/__init__.py +74 -5
- metaflow/plugins/airflow/airflow.py +40 -25
- metaflow/plugins/airflow/airflow_cli.py +22 -5
- metaflow/plugins/airflow/airflow_decorator.py +1 -1
- metaflow/plugins/airflow/airflow_utils.py +5 -3
- metaflow/plugins/airflow/sensors/base_sensor.py +4 -4
- metaflow/plugins/airflow/sensors/external_task_sensor.py +2 -2
- metaflow/plugins/airflow/sensors/s3_sensor.py +2 -2
- metaflow/plugins/argo/argo_client.py +78 -33
- metaflow/plugins/argo/argo_events.py +6 -6
- metaflow/plugins/argo/argo_workflows.py +2410 -527
- metaflow/plugins/argo/argo_workflows_cli.py +571 -121
- metaflow/plugins/argo/argo_workflows_decorator.py +43 -12
- metaflow/plugins/argo/argo_workflows_deployer.py +106 -0
- metaflow/plugins/argo/argo_workflows_deployer_objects.py +453 -0
- metaflow/plugins/argo/capture_error.py +73 -0
- metaflow/plugins/argo/conditional_input_paths.py +35 -0
- metaflow/plugins/argo/exit_hooks.py +209 -0
- metaflow/plugins/argo/jobset_input_paths.py +15 -0
- metaflow/plugins/argo/param_val.py +19 -0
- metaflow/plugins/aws/aws_client.py +10 -3
- metaflow/plugins/aws/aws_utils.py +55 -2
- metaflow/plugins/aws/batch/batch.py +72 -5
- metaflow/plugins/aws/batch/batch_cli.py +33 -10
- metaflow/plugins/aws/batch/batch_client.py +4 -3
- metaflow/plugins/aws/batch/batch_decorator.py +102 -35
- metaflow/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.py +13 -10
- metaflow/plugins/aws/step_functions/dynamo_db_client.py +0 -3
- metaflow/plugins/aws/step_functions/production_token.py +1 -1
- metaflow/plugins/aws/step_functions/step_functions.py +65 -8
- metaflow/plugins/aws/step_functions/step_functions_cli.py +101 -7
- metaflow/plugins/aws/step_functions/step_functions_decorator.py +1 -2
- metaflow/plugins/aws/step_functions/step_functions_deployer.py +97 -0
- metaflow/plugins/aws/step_functions/step_functions_deployer_objects.py +264 -0
- metaflow/plugins/azure/azure_exceptions.py +1 -1
- metaflow/plugins/azure/azure_secret_manager_secrets_provider.py +240 -0
- metaflow/plugins/azure/azure_tail.py +1 -1
- metaflow/plugins/azure/includefile_support.py +2 -0
- metaflow/plugins/cards/card_cli.py +66 -30
- metaflow/plugins/cards/card_creator.py +25 -1
- metaflow/plugins/cards/card_datastore.py +21 -49
- metaflow/plugins/cards/card_decorator.py +132 -8
- metaflow/plugins/cards/card_modules/basic.py +112 -17
- metaflow/plugins/cards/card_modules/bundle.css +1 -1
- metaflow/plugins/cards/card_modules/card.py +16 -1
- metaflow/plugins/cards/card_modules/chevron/renderer.py +1 -1
- metaflow/plugins/cards/card_modules/components.py +665 -28
- metaflow/plugins/cards/card_modules/convert_to_native_type.py +36 -7
- metaflow/plugins/cards/card_modules/json_viewer.py +232 -0
- metaflow/plugins/cards/card_modules/main.css +1 -0
- metaflow/plugins/cards/card_modules/main.js +68 -49
- metaflow/plugins/cards/card_modules/renderer_tools.py +1 -0
- metaflow/plugins/cards/card_modules/test_cards.py +26 -12
- metaflow/plugins/cards/card_server.py +39 -14
- metaflow/plugins/cards/component_serializer.py +2 -9
- metaflow/plugins/cards/metadata.py +22 -0
- metaflow/plugins/catch_decorator.py +9 -0
- metaflow/plugins/datastores/azure_storage.py +10 -1
- metaflow/plugins/datastores/gs_storage.py +6 -2
- metaflow/plugins/datastores/local_storage.py +12 -6
- metaflow/plugins/datastores/spin_storage.py +12 -0
- metaflow/plugins/datatools/local.py +2 -0
- metaflow/plugins/datatools/s3/s3.py +126 -75
- metaflow/plugins/datatools/s3/s3op.py +254 -121
- metaflow/plugins/env_escape/__init__.py +3 -3
- metaflow/plugins/env_escape/client_modules.py +102 -72
- metaflow/plugins/env_escape/server.py +7 -0
- metaflow/plugins/env_escape/stub.py +24 -5
- metaflow/plugins/events_decorator.py +343 -185
- metaflow/plugins/exit_hook/__init__.py +0 -0
- metaflow/plugins/exit_hook/exit_hook_decorator.py +46 -0
- metaflow/plugins/exit_hook/exit_hook_script.py +52 -0
- metaflow/plugins/gcp/__init__.py +1 -1
- metaflow/plugins/gcp/gcp_secret_manager_secrets_provider.py +11 -6
- metaflow/plugins/gcp/gs_tail.py +10 -6
- metaflow/plugins/gcp/includefile_support.py +3 -0
- metaflow/plugins/kubernetes/kube_utils.py +108 -0
- metaflow/plugins/kubernetes/kubernetes.py +411 -130
- metaflow/plugins/kubernetes/kubernetes_cli.py +168 -36
- metaflow/plugins/kubernetes/kubernetes_client.py +104 -2
- metaflow/plugins/kubernetes/kubernetes_decorator.py +246 -88
- metaflow/plugins/kubernetes/kubernetes_job.py +253 -581
- metaflow/plugins/kubernetes/kubernetes_jobsets.py +1071 -0
- metaflow/plugins/kubernetes/spot_metadata_cli.py +69 -0
- metaflow/plugins/kubernetes/spot_monitor_sidecar.py +109 -0
- metaflow/plugins/logs_cli.py +359 -0
- metaflow/plugins/{metadata → metadata_providers}/local.py +144 -84
- metaflow/plugins/{metadata → metadata_providers}/service.py +103 -26
- metaflow/plugins/metadata_providers/spin.py +16 -0
- metaflow/plugins/package_cli.py +36 -24
- metaflow/plugins/parallel_decorator.py +128 -11
- metaflow/plugins/parsers.py +16 -0
- metaflow/plugins/project_decorator.py +51 -5
- metaflow/plugins/pypi/bootstrap.py +357 -105
- metaflow/plugins/pypi/conda_decorator.py +82 -81
- metaflow/plugins/pypi/conda_environment.py +187 -52
- metaflow/plugins/pypi/micromamba.py +157 -47
- metaflow/plugins/pypi/parsers.py +268 -0
- metaflow/plugins/pypi/pip.py +88 -13
- metaflow/plugins/pypi/pypi_decorator.py +37 -1
- metaflow/plugins/pypi/utils.py +48 -2
- metaflow/plugins/resources_decorator.py +2 -2
- metaflow/plugins/secrets/__init__.py +3 -0
- metaflow/plugins/secrets/secrets_decorator.py +26 -181
- metaflow/plugins/secrets/secrets_func.py +49 -0
- metaflow/plugins/secrets/secrets_spec.py +101 -0
- metaflow/plugins/secrets/utils.py +74 -0
- metaflow/plugins/tag_cli.py +4 -7
- metaflow/plugins/test_unbounded_foreach_decorator.py +41 -6
- metaflow/plugins/timeout_decorator.py +3 -3
- metaflow/plugins/uv/__init__.py +0 -0
- metaflow/plugins/uv/bootstrap.py +128 -0
- metaflow/plugins/uv/uv_environment.py +72 -0
- metaflow/procpoll.py +1 -1
- metaflow/pylint_wrapper.py +5 -1
- metaflow/runner/__init__.py +0 -0
- metaflow/runner/click_api.py +717 -0
- metaflow/runner/deployer.py +470 -0
- metaflow/runner/deployer_impl.py +201 -0
- metaflow/runner/metaflow_runner.py +714 -0
- metaflow/runner/nbdeploy.py +132 -0
- metaflow/runner/nbrun.py +225 -0
- metaflow/runner/subprocess_manager.py +650 -0
- metaflow/runner/utils.py +335 -0
- metaflow/runtime.py +1078 -260
- metaflow/sidecar/sidecar_worker.py +1 -1
- metaflow/system/__init__.py +5 -0
- metaflow/system/system_logger.py +85 -0
- metaflow/system/system_monitor.py +108 -0
- metaflow/system/system_utils.py +19 -0
- metaflow/task.py +521 -225
- metaflow/tracing/__init__.py +7 -7
- metaflow/tracing/span_exporter.py +31 -38
- metaflow/tracing/tracing_modules.py +38 -43
- metaflow/tuple_util.py +27 -0
- metaflow/user_configs/__init__.py +0 -0
- metaflow/user_configs/config_options.py +563 -0
- metaflow/user_configs/config_parameters.py +598 -0
- metaflow/user_decorators/__init__.py +0 -0
- metaflow/user_decorators/common.py +144 -0
- metaflow/user_decorators/mutable_flow.py +512 -0
- metaflow/user_decorators/mutable_step.py +424 -0
- metaflow/user_decorators/user_flow_decorator.py +264 -0
- metaflow/user_decorators/user_step_decorator.py +749 -0
- metaflow/util.py +243 -27
- metaflow/vendor.py +23 -7
- metaflow/version.py +1 -1
- ob_metaflow-2.19.7.1rc0.data/data/share/metaflow/devtools/Makefile +355 -0
- ob_metaflow-2.19.7.1rc0.data/data/share/metaflow/devtools/Tiltfile +726 -0
- ob_metaflow-2.19.7.1rc0.data/data/share/metaflow/devtools/pick_services.sh +105 -0
- ob_metaflow-2.19.7.1rc0.dist-info/METADATA +87 -0
- ob_metaflow-2.19.7.1rc0.dist-info/RECORD +445 -0
- {ob_metaflow-2.11.13.1.dist-info → ob_metaflow-2.19.7.1rc0.dist-info}/WHEEL +1 -1
- {ob_metaflow-2.11.13.1.dist-info → ob_metaflow-2.19.7.1rc0.dist-info}/entry_points.txt +1 -0
- metaflow/_vendor/v3_5/__init__.py +0 -1
- metaflow/_vendor/v3_5/importlib_metadata/__init__.py +0 -644
- metaflow/_vendor/v3_5/importlib_metadata/_compat.py +0 -152
- metaflow/package.py +0 -188
- ob_metaflow-2.11.13.1.dist-info/METADATA +0 -85
- ob_metaflow-2.11.13.1.dist-info/RECORD +0 -308
- /metaflow/_vendor/{v3_5/zipp.py → zipp.py} +0 -0
- /metaflow/{metadata → metadata_provider}/__init__.py +0 -0
- /metaflow/{metadata → metadata_provider}/util.py +0 -0
- /metaflow/plugins/{metadata → metadata_providers}/__init__.py +0 -0
- {ob_metaflow-2.11.13.1.dist-info → ob_metaflow-2.19.7.1rc0.dist-info/licenses}/LICENSE +0 -0
- {ob_metaflow-2.11.13.1.dist-info → ob_metaflow-2.19.7.1rc0.dist-info}/top_level.txt +0 -0
metaflow/R.py
CHANGED
|
@@ -3,6 +3,7 @@ import sys
|
|
|
3
3
|
from importlib import util as imp_util, machinery as imp_machinery
|
|
4
4
|
from tempfile import NamedTemporaryFile
|
|
5
5
|
|
|
6
|
+
from . import parameters
|
|
6
7
|
from .util import to_bytes
|
|
7
8
|
|
|
8
9
|
R_FUNCTIONS = {}
|
|
@@ -125,15 +126,17 @@ def run(
|
|
|
125
126
|
flow = module.FLOW(use_cli=False)
|
|
126
127
|
|
|
127
128
|
from . import exception
|
|
128
|
-
from . import cli
|
|
129
129
|
|
|
130
130
|
try:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
with parameters.flow_context(flow.__class__) as _:
|
|
132
|
+
from . import cli
|
|
133
|
+
|
|
134
|
+
cli.main(
|
|
135
|
+
flow,
|
|
136
|
+
args=metaflow_args,
|
|
137
|
+
handle_exceptions=False,
|
|
138
|
+
entrypoint=full_cmdline[: -len(metaflow_args)],
|
|
139
|
+
)
|
|
137
140
|
except exception.MetaflowException as e:
|
|
138
141
|
cli.print_metaflow_exception(e)
|
|
139
142
|
os.remove(tmp.name)
|
metaflow/__init__.py
CHANGED
|
@@ -42,14 +42,8 @@ If you have any questions, feel free to post a bug report/question on the
|
|
|
42
42
|
Metaflow GitHub page.
|
|
43
43
|
"""
|
|
44
44
|
|
|
45
|
-
import
|
|
45
|
+
import os
|
|
46
46
|
import sys
|
|
47
|
-
import types
|
|
48
|
-
|
|
49
|
-
from os import path
|
|
50
|
-
|
|
51
|
-
CURRENT_DIRECTORY = path.dirname(path.abspath(__file__))
|
|
52
|
-
INFO_FILE = path.join(path.dirname(CURRENT_DIRECTORY), "INFO")
|
|
53
47
|
|
|
54
48
|
from metaflow.extension_support import (
|
|
55
49
|
alias_submodules,
|
|
@@ -61,7 +55,6 @@ from metaflow.extension_support import (
|
|
|
61
55
|
_ext_debug,
|
|
62
56
|
)
|
|
63
57
|
|
|
64
|
-
|
|
65
58
|
# We load the module overrides *first* explicitly. Non overrides can be loaded
|
|
66
59
|
# in toplevel as well but these can be loaded first if needed. Note that those
|
|
67
60
|
# modules should be careful not to include anything in Metaflow at their top-level
|
|
@@ -79,9 +72,14 @@ try:
|
|
|
79
72
|
)
|
|
80
73
|
tl_module = m.module.__dict__.get("toplevel", None)
|
|
81
74
|
if tl_module is not None:
|
|
82
|
-
_tl_modules.append(
|
|
75
|
+
_tl_modules.append(
|
|
76
|
+
(
|
|
77
|
+
m.package_name,
|
|
78
|
+
".".join([EXT_PKG, m.tl_package, "toplevel", tl_module]),
|
|
79
|
+
)
|
|
80
|
+
)
|
|
83
81
|
_ext_debug("Got overrides to load: %s" % _override_modules)
|
|
84
|
-
_ext_debug("Got top-level imports: %s" % _tl_modules)
|
|
82
|
+
_ext_debug("Got top-level imports: %s" % str(_tl_modules))
|
|
85
83
|
except Exception as e:
|
|
86
84
|
_ext_debug("Error in importing toplevel/overrides: %s" % e)
|
|
87
85
|
|
|
@@ -103,9 +101,16 @@ from .metaflow_current import current
|
|
|
103
101
|
# Flow spec
|
|
104
102
|
from .flowspec import FlowSpec
|
|
105
103
|
|
|
106
|
-
from .parameters import Parameter, JSONTypeClass
|
|
104
|
+
from .parameters import Parameter, JSONTypeClass, JSONType
|
|
107
105
|
|
|
108
|
-
|
|
106
|
+
from .user_configs.config_parameters import Config, ConfigValue, config_expr
|
|
107
|
+
from .user_decorators.user_step_decorator import (
|
|
108
|
+
UserStepDecorator,
|
|
109
|
+
StepMutator,
|
|
110
|
+
user_step_decorator,
|
|
111
|
+
USER_SKIP_STEP,
|
|
112
|
+
)
|
|
113
|
+
from .user_decorators.user_flow_decorator import FlowMutator
|
|
109
114
|
|
|
110
115
|
# data layer
|
|
111
116
|
# For historical reasons, we make metaflow.plugins.datatools accessible as
|
|
@@ -120,11 +125,17 @@ from .includefile import IncludeFile
|
|
|
120
125
|
# Decorators
|
|
121
126
|
from .decorators import step, _import_plugin_decorators
|
|
122
127
|
|
|
128
|
+
|
|
129
|
+
# Parsers (for configs) for now
|
|
130
|
+
from .plugins import _import_tl_plugins
|
|
131
|
+
|
|
132
|
+
_import_tl_plugins(globals())
|
|
133
|
+
|
|
123
134
|
# this auto-generates decorator functions from Decorator objects
|
|
124
135
|
# in the top-level metaflow namespace
|
|
125
136
|
_import_plugin_decorators(globals())
|
|
126
|
-
# Setting card import for only python 3.
|
|
127
|
-
if sys.version_info[0] >= 3 and sys.version_info[1] >=
|
|
137
|
+
# Setting card import for only python 3.6
|
|
138
|
+
if sys.version_info[0] >= 3 and sys.version_info[1] >= 6:
|
|
128
139
|
from . import cards
|
|
129
140
|
|
|
130
141
|
# Client
|
|
@@ -135,6 +146,7 @@ from .client import (
|
|
|
135
146
|
metadata,
|
|
136
147
|
get_metadata,
|
|
137
148
|
default_metadata,
|
|
149
|
+
inspect_spin,
|
|
138
150
|
Metaflow,
|
|
139
151
|
Flow,
|
|
140
152
|
Run,
|
|
@@ -143,9 +155,20 @@ from .client import (
|
|
|
143
155
|
DataArtifact,
|
|
144
156
|
)
|
|
145
157
|
|
|
146
|
-
|
|
158
|
+
# Import data class within tuple_util but not introduce new symbols.
|
|
159
|
+
from . import tuple_util
|
|
160
|
+
|
|
161
|
+
# Runner API
|
|
162
|
+
if sys.version_info >= (3, 7):
|
|
163
|
+
from .runner.metaflow_runner import Runner
|
|
164
|
+
from .runner.nbrun import NBRunner
|
|
165
|
+
from .runner.deployer import Deployer
|
|
166
|
+
from .runner.deployer import DeployedFlow
|
|
167
|
+
from .runner.nbdeploy import NBDeployer
|
|
168
|
+
|
|
169
|
+
__ext_tl_modules__ = []
|
|
147
170
|
_ext_debug("Loading top-level modules")
|
|
148
|
-
for m in _tl_modules:
|
|
171
|
+
for pkg_name, m in _tl_modules:
|
|
149
172
|
extension_module = load_module(m)
|
|
150
173
|
if extension_module:
|
|
151
174
|
tl_package = m.split(".")[1]
|
|
@@ -153,15 +176,7 @@ for m in _tl_modules:
|
|
|
153
176
|
lazy_load_aliases(
|
|
154
177
|
alias_submodules(extension_module, tl_package, None, extra_indent=True)
|
|
155
178
|
)
|
|
156
|
-
|
|
157
|
-
if extension_module.__version__:
|
|
158
|
-
version_info = "%s(%s)" % (version_info, extension_module.__version__)
|
|
159
|
-
__version_addl__.append(version_info)
|
|
160
|
-
|
|
161
|
-
if __version_addl__:
|
|
162
|
-
__version_addl__ = ";".join(__version_addl__)
|
|
163
|
-
else:
|
|
164
|
-
__version_addl__ = None
|
|
179
|
+
__ext_tl_modules__.append((pkg_name, extension_module))
|
|
165
180
|
|
|
166
181
|
# Erase all temporary names to avoid leaking things
|
|
167
182
|
for _n in [
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"""Recognize image file formats based on their first few bytes."""
|
|
2
|
+
|
|
3
|
+
from os import PathLike
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
__all__ = ["what"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# python-deadlib: Replace deprecation warning not to raise exception
|
|
10
|
+
warnings.warn(
|
|
11
|
+
f"{__name__} was removed in Python 3.13. "
|
|
12
|
+
f"Please be aware that you are currently NOT using standard '{__name__}', "
|
|
13
|
+
f"but instead a separately installed 'standard-{__name__}'.",
|
|
14
|
+
DeprecationWarning, stacklevel=2
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#-------------------------#
|
|
19
|
+
# Recognize image headers #
|
|
20
|
+
#-------------------------#
|
|
21
|
+
|
|
22
|
+
def what(file, h=None):
|
|
23
|
+
"""Return the type of image contained in a file or byte stream."""
|
|
24
|
+
f = None
|
|
25
|
+
try:
|
|
26
|
+
if h is None:
|
|
27
|
+
if isinstance(file, (str, PathLike)):
|
|
28
|
+
f = open(file, 'rb')
|
|
29
|
+
h = f.read(32)
|
|
30
|
+
else:
|
|
31
|
+
location = file.tell()
|
|
32
|
+
h = file.read(32)
|
|
33
|
+
file.seek(location)
|
|
34
|
+
for tf in tests:
|
|
35
|
+
res = tf(h, f)
|
|
36
|
+
if res:
|
|
37
|
+
return res
|
|
38
|
+
finally:
|
|
39
|
+
if f: f.close()
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
#---------------------------------#
|
|
44
|
+
# Subroutines per image file type #
|
|
45
|
+
#---------------------------------#
|
|
46
|
+
|
|
47
|
+
tests = []
|
|
48
|
+
|
|
49
|
+
def test_jpeg(h, f):
|
|
50
|
+
"""Test for JPEG data with JFIF or Exif markers; and raw JPEG."""
|
|
51
|
+
if h[6:10] in (b'JFIF', b'Exif'):
|
|
52
|
+
return 'jpeg'
|
|
53
|
+
elif h[:4] == b'\xff\xd8\xff\xdb':
|
|
54
|
+
return 'jpeg'
|
|
55
|
+
|
|
56
|
+
tests.append(test_jpeg)
|
|
57
|
+
|
|
58
|
+
def test_png(h, f):
|
|
59
|
+
"""Verify if the image is a PNG."""
|
|
60
|
+
if h.startswith(b'\211PNG\r\n\032\n'):
|
|
61
|
+
return 'png'
|
|
62
|
+
|
|
63
|
+
tests.append(test_png)
|
|
64
|
+
|
|
65
|
+
def test_gif(h, f):
|
|
66
|
+
"""Verify if the image is a GIF ('87 or '89 variants)."""
|
|
67
|
+
if h[:6] in (b'GIF87a', b'GIF89a'):
|
|
68
|
+
return 'gif'
|
|
69
|
+
|
|
70
|
+
tests.append(test_gif)
|
|
71
|
+
|
|
72
|
+
def test_tiff(h, f):
|
|
73
|
+
"""Verify if the image is a TIFF (can be in Motorola or Intel byte order)."""
|
|
74
|
+
if h[:2] in (b'MM', b'II'):
|
|
75
|
+
return 'tiff'
|
|
76
|
+
|
|
77
|
+
tests.append(test_tiff)
|
|
78
|
+
|
|
79
|
+
def test_rgb(h, f):
|
|
80
|
+
"""test for the SGI image library."""
|
|
81
|
+
if h.startswith(b'\001\332'):
|
|
82
|
+
return 'rgb'
|
|
83
|
+
|
|
84
|
+
tests.append(test_rgb)
|
|
85
|
+
|
|
86
|
+
def test_pbm(h, f):
|
|
87
|
+
"""Verify if the image is a PBM (portable bitmap)."""
|
|
88
|
+
if len(h) >= 3 and \
|
|
89
|
+
h[0] == ord(b'P') and h[1] in b'14' and h[2] in b' \t\n\r':
|
|
90
|
+
return 'pbm'
|
|
91
|
+
|
|
92
|
+
tests.append(test_pbm)
|
|
93
|
+
|
|
94
|
+
def test_pgm(h, f):
|
|
95
|
+
"""Verify if the image is a PGM (portable graymap)."""
|
|
96
|
+
if len(h) >= 3 and \
|
|
97
|
+
h[0] == ord(b'P') and h[1] in b'25' and h[2] in b' \t\n\r':
|
|
98
|
+
return 'pgm'
|
|
99
|
+
|
|
100
|
+
tests.append(test_pgm)
|
|
101
|
+
|
|
102
|
+
def test_ppm(h, f):
|
|
103
|
+
"""Verify if the image is a PPM (portable pixmap)."""
|
|
104
|
+
if len(h) >= 3 and \
|
|
105
|
+
h[0] == ord(b'P') and h[1] in b'36' and h[2] in b' \t\n\r':
|
|
106
|
+
return 'ppm'
|
|
107
|
+
|
|
108
|
+
tests.append(test_ppm)
|
|
109
|
+
|
|
110
|
+
def test_rast(h, f):
|
|
111
|
+
"""test for the Sun raster file."""
|
|
112
|
+
if h.startswith(b'\x59\xA6\x6A\x95'):
|
|
113
|
+
return 'rast'
|
|
114
|
+
|
|
115
|
+
tests.append(test_rast)
|
|
116
|
+
|
|
117
|
+
def test_xbm(h, f):
|
|
118
|
+
"""Verify if the image is a X bitmap (X10 or X11)."""
|
|
119
|
+
if h.startswith(b'#define '):
|
|
120
|
+
return 'xbm'
|
|
121
|
+
|
|
122
|
+
tests.append(test_xbm)
|
|
123
|
+
|
|
124
|
+
def test_bmp(h, f):
|
|
125
|
+
"""Verify if the image is a BMP file."""
|
|
126
|
+
if h.startswith(b'BM'):
|
|
127
|
+
return 'bmp'
|
|
128
|
+
|
|
129
|
+
tests.append(test_bmp)
|
|
130
|
+
|
|
131
|
+
def test_webp(h, f):
|
|
132
|
+
"""Verify if the image is a WebP."""
|
|
133
|
+
if h.startswith(b'RIFF') and h[8:12] == b'WEBP':
|
|
134
|
+
return 'webp'
|
|
135
|
+
|
|
136
|
+
tests.append(test_webp)
|
|
137
|
+
|
|
138
|
+
def test_exr(h, f):
|
|
139
|
+
"""verify is the image ia a OpenEXR fileOpenEXR."""
|
|
140
|
+
if h.startswith(b'\x76\x2f\x31\x01'):
|
|
141
|
+
return 'exr'
|
|
142
|
+
|
|
143
|
+
tests.append(test_exr)
|
|
144
|
+
|
|
145
|
+
#--------------------#
|
|
146
|
+
# Small test program #
|
|
147
|
+
#--------------------#
|
|
148
|
+
|
|
149
|
+
def test():
|
|
150
|
+
import sys
|
|
151
|
+
recursive = 0
|
|
152
|
+
if sys.argv[1:] and sys.argv[1] == '-r':
|
|
153
|
+
del sys.argv[1:2]
|
|
154
|
+
recursive = 1
|
|
155
|
+
try:
|
|
156
|
+
if sys.argv[1:]:
|
|
157
|
+
testall(sys.argv[1:], recursive, 1)
|
|
158
|
+
else:
|
|
159
|
+
testall(['.'], recursive, 1)
|
|
160
|
+
except KeyboardInterrupt:
|
|
161
|
+
sys.stderr.write('\n[Interrupted]\n')
|
|
162
|
+
sys.exit(1)
|
|
163
|
+
|
|
164
|
+
def testall(list, recursive, toplevel):
|
|
165
|
+
import sys
|
|
166
|
+
import os
|
|
167
|
+
for filename in list:
|
|
168
|
+
if os.path.isdir(filename):
|
|
169
|
+
print(filename + '/:', end=' ')
|
|
170
|
+
if recursive or toplevel:
|
|
171
|
+
print('recursing down:')
|
|
172
|
+
import glob
|
|
173
|
+
names = glob.glob(os.path.join(glob.escape(filename), '*'))
|
|
174
|
+
testall(names, recursive, 0)
|
|
175
|
+
else:
|
|
176
|
+
print('*** directory (use -r) ***')
|
|
177
|
+
else:
|
|
178
|
+
print(filename + ':', end=' ')
|
|
179
|
+
sys.stdout.flush()
|
|
180
|
+
try:
|
|
181
|
+
print(what(filename))
|
|
182
|
+
except OSError:
|
|
183
|
+
print('*** not found ***')
|
|
184
|
+
|
|
185
|
+
if __name__ == '__main__':
|
|
186
|
+
test()
|