Skip to content

Commit

Permalink
Merge pull request #598 from linsword13/pkgman-mirror
Browse files Browse the repository at this point in the history
Issue a warning when mirror with pip package manager
  • Loading branch information
douglasjacobsen authored Aug 8, 2024
2 parents f4744cd + 5580ea2 commit 71c1198
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
67 changes: 67 additions & 0 deletions lib/ramble/ramble/test/end_to_end/warn_mirror_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright 2022-2024 The Ramble Authors
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

import glob
import os

import pytest

import ramble.workspace
from ramble.main import RambleCommand
from ramble.test.dry_run_helpers import search_files_for_string

pytestmark = pytest.mark.usefixtures(
"mutable_config",
"mutable_mock_workspace_path",
)

workspace = RambleCommand("workspace")


def assert_text_in_mirror_logs(ws, text):
mirror_logs = glob.glob(os.path.join(ws.log_dir, "**", "*.out"))
assert search_files_for_string(mirror_logs, text)


def test_warn_mirror_support(tmpdir):
test_config = """
ramble:
variants:
package_manager: pip
variables:
mpi_command: ''
batch_submit: '{execute_experiment}'
processes_per_node: 1
n_ranks: 1
applications:
hostname:
workloads:
local:
experiments:
test: {}
software:
packages: {}
environments: {}
"""
ws_name = "test_pip_mirror_support"
ws = ramble.workspace.create(ws_name)
ramble.workspace.activate(ws)
ws.write()

config_path = os.path.join(ws.config_dir, ramble.workspace.config_file_name)

with open(config_path, "w+") as f:
f.write(test_config)

ws._re_read()

mirror_path = os.path.join(tmpdir, ws_name)
workspace("mirror", "--dry-run", "-d", mirror_path)
assert_text_in_mirror_logs(
ws, "Warning: Mirroring software using pip is not currently supported"
)
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ def populate_inventory(
}
)

register_phase("warn_mirror_support", pipeline="mirror")

def _warn_mirror_support(self, workspace, app_inst=None):
del workspace, app_inst # unused arguments
logger.warn(
f"Mirroring software using {self.name} is not currently supported. "
"If a software mirror is required, it needs to be set up outside of Ramble"
)


package_name_regex = re.compile(
r"\s*(?P<pkg_name>[A-Z0-9][A-Z0-9._-]*[A-Z0-9]|[A-Z0-9]).*", re.IGNORECASE
Expand Down

0 comments on commit 71c1198

Please sign in to comment.