Skip to content

Commit

Permalink
Move test flag up
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-intel committed Aug 8, 2024
1 parent 9da2993 commit dcf7b2e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 29 deletions.
69 changes: 43 additions & 26 deletions metaflow_extensions/netflix_ext/plugins/conda/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
CONDA_PREFERRED_FORMAT,
CONDA_REMOTE_INSTALLER,
CONDA_REMOTE_INSTALLER_DIRNAME,
CONDA_TEST,
CONDA_DEFAULT_PYPI_SOURCE,
CONDA_USE_REMOTE_LATEST,
)
Expand Down Expand Up @@ -139,7 +140,7 @@ def _modified_logger(*args: Any, **kwargs: Any):
self._cached_environment = read_conda_manifest(self._local_root)

# Initialize storage
if self._datastore_type != "local":
if self._datastore_type != "local" or CONDA_TEST:
# Prevent circular dep
from metaflow.plugins import DATASTORES

Expand Down Expand Up @@ -284,15 +285,19 @@ def call_conda(
except subprocess.CalledProcessError as e:
if pretty_print_exception:
print(
"Pretty-printed STDOUT:\n%s" % e.output.decode("utf-8")
if e.output
else "No STDOUT",
(
"Pretty-printed STDOUT:\n%s" % e.output.decode("utf-8")
if e.output
else "No STDOUT"
),
file=sys.stderr,
)
print(
"Pretty-printed STDERR:\n%s" % e.stderr.decode("utf-8")
if e.stderr
else "No STDERR",
(
"Pretty-printed STDERR:\n%s" % e.stderr.decode("utf-8")
if e.stderr
else "No STDERR"
),
file=sys.stderr,
)
raise CondaException(
Expand Down Expand Up @@ -334,15 +339,19 @@ def call_binary(
).strip()
except subprocess.CalledProcessError as e:
print(
"Pretty-printed STDOUT:\n%s" % e.output.decode("utf-8")
if e.output
else "No STDOUT",
(
"Pretty-printed STDOUT:\n%s" % e.output.decode("utf-8")
if e.output
else "No STDOUT"
),
file=sys.stderr,
)
print(
"Pretty-printed STDERR:\n%s" % e.stderr.decode("utf-8")
if e.stderr
else "No STDERR",
(
"Pretty-printed STDERR:\n%s" % e.stderr.decode("utf-8")
if e.stderr
else "No STDERR"
),
file=sys.stderr,
)
raise CondaException(
Expand Down Expand Up @@ -863,7 +872,7 @@ def alias_environment(self, env_id: EnvID, aliases: List[str]) -> None:
The list of aliases -- note that you can only update mutable aliases or
add new ones.
"""
if self._datastore_type != "local":
if self._datastore_type != "local" or CONDA_TEST:
# We first fetch any aliases we have remotely because that way
# we will catch any non-mutable changes
resolved_aliases = [resolve_env_alias(a) for a in aliases]
Expand Down Expand Up @@ -965,9 +974,11 @@ def cache_environments(
my_arch_id = arch_id()
cache_formats = cache_formats or {
"pypi": ["_any"],
"conda": [CONDA_PREFERRED_FORMAT]
if CONDA_PREFERRED_FORMAT and CONDA_PREFERRED_FORMAT != "none"
else ["_any"],
"conda": (
[CONDA_PREFERRED_FORMAT]
if CONDA_PREFERRED_FORMAT and CONDA_PREFERRED_FORMAT != "none"
else ["_any"]
),
}

# key: URL
Expand Down Expand Up @@ -2382,9 +2393,11 @@ def _create(self, env: ResolvedEnvironment, env_name: str) -> str:
args,
# Creating with micromamba is faster as it extracts in parallel. Prefer
# it if it exists.
binary="micromamba"
if self._bins and "micromamba" in self._bins
else "conda",
binary=(
"micromamba"
if self._bins and "micromamba" in self._bins
else "conda"
),
)

if pypi_paths:
Expand Down Expand Up @@ -2412,15 +2425,19 @@ def _create(self, env: ResolvedEnvironment, env_name: str) -> str:
subprocess.check_output(arg_list, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print(
"Pretty-printed STDOUT:\n%s" % e.output.decode("utf-8")
if e.output
else "No STDOUT",
(
"Pretty-printed STDOUT:\n%s" % e.output.decode("utf-8")
if e.output
else "No STDOUT"
),
file=sys.stderr,
)
print(
"Pretty-printed STDERR:\n%s" % e.stderr.decode("utf-8")
if e.stderr
else "No STDERR",
(
"Pretty-printed STDERR:\n%s" % e.stderr.decode("utf-8")
if e.stderr
else "No STDERR"
),
file=sys.stderr,
)
raise CondaException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

from metaflow.debug import debug

from metaflow.metaflow_config import CONDA_TEST

from ..env_descr import (
EnvType,
PackageSpecification,
Expand Down Expand Up @@ -536,7 +534,7 @@ def resolve(
)
)
if to_build_pkg_info:
if not self._conda.storage and not CONDA_TEST:
if not self._conda.storage:
raise CondaException(
"Cannot create a relocatable environment as it depends on "
"local files or non wheels and no storage backend is defined: %s"
Expand Down

0 comments on commit dcf7b2e

Please sign in to comment.