Skip to content

Commit

Permalink
prevent tracing module loading during conda bootstrapping process.
Browse files Browse the repository at this point in the history
  • Loading branch information
saikonen committed Oct 18, 2023
1 parent c4e4d3d commit 9c31d3b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions metaflow/metaflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@
OTEL_ENDPOINT = from_conf("OTEL_ENDPOINT")
ZIPKIN_ENDPOINT = from_conf("ZIPKIN_ENDPOINT")
CONSOLE_TRACE_ENABLED = from_conf("CONSOLE_TRACE_ENABLED", False)
# internal env used for preventing the tracing module from loading during Conda bootstrapping.
BOOTSTRAPPING_CONDA_ENVIRONMENT = bool(
os.environ.get("BOOTSTRAPPING_CONDA_ENVIRONMENT", False)
)

# MAX_ATTEMPTS is the maximum number of attempts, including the first
# task, retries, and the final fallback task and its retries.
Expand Down
6 changes: 5 additions & 1 deletion metaflow/plugins/pypi/conda_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ def bootstrap_commands(self, step_name, datastore_type):
if id_:
return [
"echo 'Bootstrapping virtual environment...'",
'python -m metaflow.plugins.pypi.bootstrap "%s" %s "%s" linux-64'
# We have to prevent the tracing module from loading,
# as the bootstrapping process uses the internal S3 client which would fail to import tracing
# due to the required dependencies being bundled into the conda environment,
# which is yet to be initialized at this point.
'BOOTSTRAPPING_CONDA_ENVIRONMENT=True python -m metaflow.plugins.pypi.bootstrap "%s" %s "%s" linux-64'
% (self.flow.name, id_, self.datastore_type),
"echo 'Environment bootstrapped.'",
"export PATH=$PATH:$(pwd)/micromamba",
Expand Down
5 changes: 4 additions & 1 deletion metaflow/tracing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
OTEL_ENDPOINT,
ZIPKIN_ENDPOINT,
CONSOLE_TRACE_ENABLED,
BOOTSTRAPPING_CONDA_ENVIRONMENT,
)
from functools import wraps
import contextlib
Expand Down Expand Up @@ -49,7 +50,9 @@ def wrapper_func(*args, **kwargs):
return wrapper_func


if CONSOLE_TRACE_ENABLED or OTEL_ENDPOINT or ZIPKIN_ENDPOINT:
if not BOOTSTRAPPING_CONDA_ENVIRONMENT and (
CONSOLE_TRACE_ENABLED or OTEL_ENDPOINT or ZIPKIN_ENDPOINT
):
try:
from .tracing_modules import *

Expand Down

0 comments on commit 9c31d3b

Please sign in to comment.