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/tracing/__init__.py
CHANGED
|
@@ -20,15 +20,15 @@ def post_fork():
|
|
|
20
20
|
yield
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def
|
|
24
|
-
def
|
|
23
|
+
def cli(name: str):
|
|
24
|
+
def cli_wrap(func):
|
|
25
25
|
@wraps(func)
|
|
26
26
|
def wrapper_func(*args, **kwargs):
|
|
27
27
|
return func(*args, **kwargs)
|
|
28
28
|
|
|
29
29
|
return wrapper_func
|
|
30
30
|
|
|
31
|
-
return
|
|
31
|
+
return cli_wrap
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def inject_tracing_vars(env_dict: Dict[str, str]) -> Dict[str, str]:
|
|
@@ -40,7 +40,9 @@ def get_trace_id() -> str:
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
@contextlib.contextmanager
|
|
43
|
-
def traced(name, attrs=
|
|
43
|
+
def traced(name, attrs=None):
|
|
44
|
+
if attrs is None:
|
|
45
|
+
attrs = {}
|
|
44
46
|
yield
|
|
45
47
|
|
|
46
48
|
|
|
@@ -54,17 +56,15 @@ def tracing(func):
|
|
|
54
56
|
|
|
55
57
|
if not DISABLE_TRACING and (CONSOLE_TRACE_ENABLED or OTEL_ENDPOINT or ZIPKIN_ENDPOINT):
|
|
56
58
|
try:
|
|
57
|
-
# Overrides No-Op implementations if a specific provider is configured.
|
|
58
59
|
from .tracing_modules import (
|
|
59
60
|
init_tracing,
|
|
60
61
|
post_fork,
|
|
61
|
-
|
|
62
|
+
cli,
|
|
62
63
|
inject_tracing_vars,
|
|
63
64
|
get_trace_id,
|
|
64
65
|
traced,
|
|
65
66
|
tracing,
|
|
66
67
|
)
|
|
67
|
-
|
|
68
68
|
except ImportError as e:
|
|
69
69
|
# We keep the errors silent by default so that having tracing environment variables present
|
|
70
70
|
# does not affect users with no need for tracing.
|
|
@@ -3,6 +3,8 @@ from metaflow.metaflow_config import (
|
|
|
3
3
|
OTEL_ENDPOINT,
|
|
4
4
|
ZIPKIN_ENDPOINT,
|
|
5
5
|
CONSOLE_TRACE_ENABLED,
|
|
6
|
+
SERVICE_AUTH_KEY,
|
|
7
|
+
SERVICE_HEADERS,
|
|
6
8
|
)
|
|
7
9
|
|
|
8
10
|
if OTEL_ENDPOINT:
|
|
@@ -11,56 +13,47 @@ if OTEL_ENDPOINT:
|
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
def get_span_exporter():
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
exporter_map = {
|
|
17
|
+
OTEL_ENDPOINT: _create_otel_exporter,
|
|
18
|
+
ZIPKIN_ENDPOINT: _create_zipkin_exporter,
|
|
19
|
+
CONSOLE_TRACE_ENABLED: _create_console_exporter,
|
|
20
|
+
}
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
for config, create_exporter in exporter_map.items():
|
|
23
|
+
if config:
|
|
24
|
+
return create_exporter()
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
else:
|
|
23
|
-
print("WARNING: endpoints not set up for Opentelemetry", file=sys.stderr)
|
|
24
|
-
return
|
|
26
|
+
print("WARNING: endpoints not set up for OpenTelemetry", file=sys.stderr)
|
|
27
|
+
return None
|
|
25
28
|
|
|
26
29
|
|
|
27
|
-
def
|
|
30
|
+
def _create_otel_exporter():
|
|
28
31
|
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
if not any([SERVICE_AUTH_KEY, SERVICE_HEADERS]):
|
|
34
|
+
print("WARNING: no auth settings for OpenTelemetry", file=sys.stderr)
|
|
35
|
+
return None
|
|
36
|
+
|
|
37
|
+
config = {
|
|
38
|
+
"endpoint": OTEL_ENDPOINT,
|
|
39
|
+
"timeout": 15,
|
|
40
|
+
}
|
|
34
41
|
|
|
35
42
|
if SERVICE_AUTH_KEY:
|
|
36
|
-
|
|
37
|
-
endpoint=OTEL_ENDPOINT,
|
|
38
|
-
headers={"x-api-key": SERVICE_AUTH_KEY},
|
|
39
|
-
timeout=15,
|
|
40
|
-
)
|
|
43
|
+
config["headers"] = {"x-api-key": SERVICE_AUTH_KEY}
|
|
41
44
|
elif SERVICE_HEADERS:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
print("WARNING: no auth settings for Opentelemetry", file=sys.stderr)
|
|
49
|
-
return
|
|
50
|
-
return span_exporter
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def set_zipkin_exporter():
|
|
45
|
+
config["headers"] = SERVICE_HEADERS
|
|
46
|
+
|
|
47
|
+
return OTLPSpanExporter(**config)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _create_zipkin_exporter():
|
|
54
51
|
from opentelemetry.exporter.zipkin.proto.http import ZipkinExporter
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
endpoint=ZIPKIN_ENDPOINT,
|
|
58
|
-
)
|
|
59
|
-
return span_exporter
|
|
53
|
+
return ZipkinExporter(endpoint=ZIPKIN_ENDPOINT)
|
|
60
54
|
|
|
61
55
|
|
|
62
|
-
def
|
|
56
|
+
def _create_console_exporter():
|
|
63
57
|
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
|
|
64
58
|
|
|
65
|
-
|
|
66
|
-
return span_exporter
|
|
59
|
+
return ConsoleSpanExporter()
|
|
@@ -13,29 +13,31 @@ from typing import Dict, List, Optional
|
|
|
13
13
|
from opentelemetry import trace as trace_api, context
|
|
14
14
|
from .span_exporter import get_span_exporter
|
|
15
15
|
|
|
16
|
-
tracer_provider = None
|
|
16
|
+
tracer_provider: Optional[TracerProvider] = None
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def init_tracing():
|
|
20
20
|
global tracer_provider
|
|
21
|
+
# Disable logging from opentelemetry
|
|
22
|
+
import logging
|
|
23
|
+
logging.getLogger("opentelemetry").setLevel(logging.FATAL)
|
|
21
24
|
if tracer_provider is not None:
|
|
22
|
-
print("Tracing already initialized", file=sys.stderr)
|
|
23
25
|
return
|
|
24
26
|
|
|
25
27
|
from .propagator import EnvPropagator
|
|
26
28
|
|
|
27
29
|
set_global_textmap(EnvPropagator(None))
|
|
28
|
-
span_exporter = get_span_exporter()
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
service_name = "metaflow-awsbatch"
|
|
34
|
-
else:
|
|
35
|
-
service_name = "metaflow-local"
|
|
31
|
+
span_exporter = get_span_exporter()
|
|
32
|
+
if span_exporter is None:
|
|
33
|
+
return
|
|
36
34
|
|
|
37
35
|
tracer_provider = TracerProvider(
|
|
38
|
-
resource=Resource.create(
|
|
36
|
+
resource=Resource.create(
|
|
37
|
+
{
|
|
38
|
+
SERVICE_NAME: "metaflow",
|
|
39
|
+
}
|
|
40
|
+
)
|
|
39
41
|
)
|
|
40
42
|
trace_api.set_tracer_provider(tracer_provider)
|
|
41
43
|
|
|
@@ -45,7 +47,9 @@ def init_tracing():
|
|
|
45
47
|
try:
|
|
46
48
|
from opentelemetry.instrumentation.requests import RequestsInstrumentor
|
|
47
49
|
|
|
48
|
-
RequestsInstrumentor().instrument(
|
|
50
|
+
RequestsInstrumentor().instrument(
|
|
51
|
+
tracer_provider=tracer_provider,
|
|
52
|
+
)
|
|
49
53
|
except ImportError:
|
|
50
54
|
# Its possible that this environment has opentelemetry but not requests
|
|
51
55
|
# instrumentation. We don't want to fail in that case.
|
|
@@ -55,8 +59,10 @@ def init_tracing():
|
|
|
55
59
|
@contextlib.contextmanager
|
|
56
60
|
def post_fork():
|
|
57
61
|
global tracer_provider
|
|
62
|
+
|
|
58
63
|
tracer_provider = None
|
|
59
64
|
init_tracing()
|
|
65
|
+
|
|
60
66
|
token = context.attach(extract(os.environ))
|
|
61
67
|
try:
|
|
62
68
|
tracer = trace_api.get_tracer_provider().get_tracer(__name__)
|
|
@@ -64,47 +70,27 @@ def post_fork():
|
|
|
64
70
|
"fork", kind=trace_api.SpanKind.SERVER
|
|
65
71
|
) as span:
|
|
66
72
|
span.set_attribute("cmd", " ".join(sys.argv))
|
|
73
|
+
span.set_attribute("pid", str(os.getpid()))
|
|
67
74
|
yield
|
|
68
75
|
finally:
|
|
69
76
|
context.detach(token)
|
|
70
77
|
|
|
71
78
|
|
|
72
|
-
def
|
|
73
|
-
|
|
74
|
-
if i > 0 and tokens[i - 1] == before_token:
|
|
75
|
-
return tok
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def cli_entrypoint(name: str):
|
|
79
|
-
def cli_entrypoint_wrap(func):
|
|
79
|
+
def cli(name: str):
|
|
80
|
+
def cli_wrap(func):
|
|
80
81
|
@wraps(func)
|
|
81
82
|
def wrapper_func(*args, **kwargs):
|
|
82
83
|
global tracer_provider
|
|
83
|
-
|
|
84
84
|
init_tracing()
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
if tracer_provider is None:
|
|
87
|
+
return func(*args, **kwargs)
|
|
87
88
|
|
|
88
89
|
token = context.attach(extract(os.environ))
|
|
89
90
|
try:
|
|
90
91
|
tracer = trace_api.get_tracer_provider().get_tracer(__name__)
|
|
91
|
-
|
|
92
|
-
card_subcommand = _extract_token_after(sys.argv, "card")
|
|
93
|
-
|
|
94
|
-
step_name = _extract_token_after(sys.argv, "step")
|
|
95
|
-
task_id = _extract_token_after(sys.argv, "--task-id")
|
|
96
|
-
run_id = _extract_token_after(sys.argv, "--run-id")
|
|
97
|
-
if step_name and task_id and run_id:
|
|
98
|
-
better_name = "/".join([run_id, step_name, task_id])
|
|
99
|
-
elif card_subcommand:
|
|
100
|
-
better_name = "card/" + card_subcommand
|
|
101
|
-
elif "run" in sys.argv:
|
|
102
|
-
better_name = "run"
|
|
103
|
-
else:
|
|
104
|
-
better_name = None
|
|
105
|
-
|
|
106
92
|
with tracer.start_as_current_span(
|
|
107
|
-
|
|
93
|
+
name, kind=trace_api.SpanKind.SERVER
|
|
108
94
|
) as span:
|
|
109
95
|
span.set_attribute("cmd", " ".join(sys.argv))
|
|
110
96
|
span.set_attribute("pid", str(os.getpid()))
|
|
@@ -118,7 +104,7 @@ def cli_entrypoint(name: str):
|
|
|
118
104
|
|
|
119
105
|
return wrapper_func
|
|
120
106
|
|
|
121
|
-
return
|
|
107
|
+
return cli_wrap
|
|
122
108
|
|
|
123
109
|
|
|
124
110
|
def inject_tracing_vars(env_dict: Dict[str, str]) -> Dict[str, str]:
|
|
@@ -127,23 +113,32 @@ def inject_tracing_vars(env_dict: Dict[str, str]) -> Dict[str, str]:
|
|
|
127
113
|
|
|
128
114
|
|
|
129
115
|
def get_trace_id() -> str:
|
|
130
|
-
|
|
116
|
+
try:
|
|
117
|
+
return format_trace_id(trace_api.get_current_span().get_span_context().trace_id)
|
|
118
|
+
except Exception:
|
|
119
|
+
return ""
|
|
131
120
|
|
|
132
121
|
|
|
133
122
|
@contextlib.contextmanager
|
|
134
|
-
def traced(name, attrs=
|
|
123
|
+
def traced(name: str, attrs: Optional[Dict] = None):
|
|
124
|
+
if tracer_provider is None:
|
|
125
|
+
yield
|
|
126
|
+
return
|
|
135
127
|
tracer = trace_api.get_tracer_provider().get_tracer(__name__)
|
|
136
128
|
with tracer.start_as_current_span(name) as span:
|
|
137
|
-
|
|
138
|
-
|
|
129
|
+
if attrs:
|
|
130
|
+
for k, v in attrs.items():
|
|
131
|
+
span.set_attribute(k, v)
|
|
139
132
|
yield
|
|
140
133
|
|
|
141
134
|
|
|
142
135
|
def tracing(func):
|
|
143
136
|
@wraps(func)
|
|
144
137
|
def wrapper_func(*args, **kwargs):
|
|
145
|
-
|
|
138
|
+
if tracer_provider is None:
|
|
139
|
+
return func(*args, **kwargs)
|
|
146
140
|
|
|
141
|
+
tracer = trace_api.get_tracer_provider().get_tracer(func.__module__)
|
|
147
142
|
with tracer.start_as_current_span(func.__name__):
|
|
148
143
|
return func(*args, **kwargs)
|
|
149
144
|
|
metaflow/tuple_util.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Keep this file minimum dependency as this will be imported by metaflow at bootup.
|
|
2
|
+
def namedtuple_with_defaults(typename, field_descr, defaults=()):
|
|
3
|
+
from typing import NamedTuple
|
|
4
|
+
|
|
5
|
+
T = NamedTuple(typename, field_descr)
|
|
6
|
+
T.__new__.__defaults__ = tuple(defaults)
|
|
7
|
+
|
|
8
|
+
# Adding the following to ensure the named tuple can be (un)pickled correctly.
|
|
9
|
+
import __main__
|
|
10
|
+
|
|
11
|
+
setattr(__main__, T.__name__, T)
|
|
12
|
+
T.__module__ = "__main__"
|
|
13
|
+
return T
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Define the namedtuple with default here if they need to be accessible in client
|
|
17
|
+
# (and w/o a real flow).
|
|
18
|
+
foreach_frame_field_list = [
|
|
19
|
+
("step", str),
|
|
20
|
+
("var", str),
|
|
21
|
+
("num_splits", int),
|
|
22
|
+
("index", int),
|
|
23
|
+
("value", str),
|
|
24
|
+
]
|
|
25
|
+
ForeachFrame = namedtuple_with_defaults(
|
|
26
|
+
"ForeachFrame", foreach_frame_field_list, (None,) * (len(foreach_frame_field_list))
|
|
27
|
+
)
|
|
File without changes
|