Skip to content

Commit

Permalink
More attempts to fix out of space issue
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-intel committed Aug 8, 2024
1 parent 1c7a122 commit b3193b1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from metaflow.plugins import DATASTORES
from metaflow.metaflow_config import (
CONDA_ALL_ARCHS,
CONDA_TEST,
CONDA_SYS_DEPENDENCIES,
DEFAULT_DATASTORE,
DEFAULT_METADATA,
Expand Down Expand Up @@ -359,7 +360,7 @@ def create(
)
resolver.resolve_environments(obj.echo)
update_envs = [] # type: List[ResolvedEnvironment]
if obj.datastore_type != "local":
if obj.datastore_type != "local" or CONDA_TEST:
# We may need to update caches
# Note that it is possible that something we needed to resolve, we don't need
# to cache (if we resolved to something already cached).
Expand Down Expand Up @@ -823,9 +824,9 @@ def resolve(
sources,
new_extras,
base_env=base_env if using_str else None,
base_from_full_id=base_env.is_info_accurate
if base_env and using_str
else False,
base_from_full_id=(
base_env.is_info_accurate if base_env and using_str else False
),
local_only=local_only,
force=force,
force_co_resolve=len(archs) > 1,
Expand Down Expand Up @@ -881,7 +882,7 @@ def resolve(
# If this is not a dry-run, we cache the environments and write out the resolved
# information
update_envs = [] # type: List[ResolvedEnvironment]
if obj.datastore_type != "local":
if obj.datastore_type != "local" or CONDA_TEST:
# We may need to update caches
# Note that it is possible that something we needed to resolve, we don't need
# to cache (if we resolved to something already cached).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from metaflow.metaflow_config import (
CONDA_MAGIC_FILE_V2,
CONDA_REMOTE_COMMANDS,
CONDA_TEST,
get_pinned_conda_libs,
)

Expand Down Expand Up @@ -139,7 +140,7 @@ def init_environment(self, echo: Callable[..., None]):
resolver.resolve_environments(echo)

update_envs = [] # type: List[ResolvedEnvironment]
if self._datastore_type != "local":
if self._datastore_type != "local" or CONDA_TEST:
# We may need to update caches
# Note that it is possible that something we needed to resolve, we don't need
# to cache (if we resolved to something already cached).
Expand Down
18 changes: 11 additions & 7 deletions metaflow_extensions/netflix_ext/plugins/environment_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from metaflow._vendor import click

from metaflow.exception import CommandException
from metaflow.metaflow_config import CONDA_PREFERRED_FORMAT
from metaflow.metaflow_config import CONDA_PREFERRED_FORMAT, CONDA_TEST

from .conda.conda import Conda
from .conda.conda_common_decorator import StepRequirement
Expand Down Expand Up @@ -203,7 +203,7 @@ def resolve(
# If this is not a dry-run, we cache the environments and write out the resolved
# information
update_envs = [] # type: List[ResolvedEnvironment]
if obj.flow_datastore.TYPE != "local":
if obj.flow_datastore.TYPE != "local" or CONDA_TEST:
# We may need to update caches
# Note that it is possible that something we needed to resolve, we don't need
# to cache (if we resolved to something already cached).
Expand Down Expand Up @@ -282,12 +282,16 @@ def show(obj: Any, local_only: bool, steps_to_show: Tuple[str]):
result[step.name]["env"] = resolved_env
result[step.name]["state"].append("resolved")

if obj.flow_datastore.TYPE != "local" and resolved_env.is_cached(
if (
obj.flow_datastore.TYPE != "local" or CONDA_TEST
) and resolved_env.is_cached(
{
"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"]
)
}
):
result[step.name]["state"].append("cached")
Expand Down
1 change: 0 additions & 1 deletion tests/checks/corner-cases.txt.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ foo,1.0.0,1.0.0
outlier_detector,0.0.3,0.0.3
transnetv2,1.0.0,1.0.0
clip,1.0,1.0
pandas,0.24.0,
23 changes: 23 additions & 0 deletions tests/test_env_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import uuid
import pytest
import shutil

import sh

Expand Down Expand Up @@ -57,6 +58,8 @@ def test_resolve_and_check_env(capsys, python_version, file_type, file_name, ali
os.chdir(my_dir)
try:
env_dict = dict(os.environ)
env_dict["METAFLOW_CONDA_ENVS_DIRNAME"] = "testing/envs_%s" % conda_rand
env_dict["METAFLOW_CONDA_PACKAGES_DIRNAME"] = "testing/packages_%s" % conda_rand
env_dict["METAFLOW_CONDA_MAGIC_FILE_V2"] = "condav2-%s.cnd" % conda_rand
env_dict[
"METAFLOW_CONDA_LOCK_TIMEOUT"
Expand Down Expand Up @@ -117,3 +120,23 @@ def test_resolve_and_check_env(capsys, python_version, file_type, file_name, ali
)
finally:
os.chdir(cwd)
# Runners run out of space so clear out all the packages and environments we created/downloaded
# This does not remove the conda/mamba/micromamba environments though
shutil.rmtree(
os.path.join(
os.environ["METAFLOW_DATASTORE_SYSROOT_LOCAL"],
"conda_env",
"testing",
"envs_%s" % conda_rand,
),
ignore_errors=True,
)
shutil.rmtree(
os.path.join(
os.environ["METAFLOW_DATASTORE_SYSROOT_LOCAL"],
"conda_env",
"testing",
"packages_%s" % conda_rand,
),
ignore_errors=True,
)

0 comments on commit b3193b1

Please sign in to comment.