From 714c5de00a7a98fce9ae7114610fa87b8609cb8d Mon Sep 17 00:00:00 2001 From: Satrajit Ghosh <satra@mit.edu> Date: Sat, 14 Jan 2023 13:34:30 -0500 Subject: [PATCH 1/3] fix: adjust optionEatAll for click >= 8 --- neurodocker/cli/generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neurodocker/cli/generate.py b/neurodocker/cli/generate.py index 08141f73..3fa5ffd6 100644 --- a/neurodocker/cli/generate.py +++ b/neurodocker/cli/generate.py @@ -138,7 +138,6 @@ def parser_process(value, state): if not done: value.append(state.rargs.pop(0)) value = tuple(value) - # call the actual process self._previous_parser_process(value, state) @@ -221,6 +220,7 @@ def _get_common_renderer_params() -> ty.List[click.Parameter]: OptionEatAll( ["--install"], multiple=True, + type=tuple, help="Install packages with system package manager", ), OptionEatAll( From 9792c6aea8ed75dad2e593b9e4f6b8bd082cfd0e Mon Sep 17 00:00:00 2001 From: Satrajit Ghosh <satra@mit.edu> Date: Sat, 14 Jan 2023 15:38:57 -0500 Subject: [PATCH 2/3] remove minify option and tests --- neurodocker/cli/cli.py | 7 +++++-- neurodocker/cli/minify/_trace.sh | 6 ++---- neurodocker/cli/minify/tests/test_minify.py | 7 +++++-- neurodocker/reproenv/tests/test_state.py | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/neurodocker/cli/cli.py b/neurodocker/cli/cli.py index 995cc3d6..a44ad7ce 100644 --- a/neurodocker/cli/cli.py +++ b/neurodocker/cli/cli.py @@ -10,7 +10,7 @@ def cli(): """Generate custom containers, and minify existing containers. - The minify command is available only if Docker is installed and running. + Note: The minify command has been removed due to lack of ptrace in docker. """ @@ -20,11 +20,14 @@ def cli(): # `docker-py` is required for minification but is not installed by default. # We also pass if there is an error retrieving the Docker client. # Say, for example, the Docker engine is not running (or it is not installed). +""" +# Removing minify due to lack of ptrace availability in docker + try: from neurodocker.cli.minify.trace import minify - cli.add_command(minify) except (ImportError, RuntimeError): # TODO: should we log a debug message? We don't even have a logger at the # time of writing, so probably not. pass +""" diff --git a/neurodocker/cli/minify/_trace.sh b/neurodocker/cli/minify/_trace.sh index 256deb0d..f9f04861 100644 --- a/neurodocker/cli/minify/_trace.sh +++ b/neurodocker/cli/minify/_trace.sh @@ -40,14 +40,12 @@ function install_missing_dependencies() { function install_conda_reprozip() { TMP_CONDA_INSTALLER=/tmp/miniconda.sh ls /tmp - curl -sSL -o "$TMP_CONDA_INSTALLER" "$CONDA_URL" - ls /tmp + curl -sSL -o "$TMP_CONDA_INSTALLER" "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh" bash $TMP_CONDA_INSTALLER -b -f -p $REPROZIP_CONDA rm -f $TMP_CONDA_INSTALLER - ${REPROZIP_CONDA}/bin/python -m pip install --no-cache-dir reprozip + ${REPROZIP_CONDA}/bin/mamba install -c conda-forge -y reprozip } - function run_reprozip_trace() { # https://askubuntu.com/a/674347 cmds=("$@") diff --git a/neurodocker/cli/minify/tests/test_minify.py b/neurodocker/cli/minify/tests/test_minify.py index 70969cec..9aa8c659 100644 --- a/neurodocker/cli/minify/tests/test_minify.py +++ b/neurodocker/cli/minify/tests/test_minify.py @@ -8,9 +8,11 @@ docker = pytest.importorskip("docker", reason="docker-py not found") +@pytest.mark.skip(reason="ptrace no longer supported under docker") def test_minify(): client = docker.from_env() - container = client.containers.run("python:3.9-slim", detach=True, tty=True) + container = client.containers.run("python:3.9-slim", detach=True, tty=True, + platform="Linux/amd64", privileged=True) commands = ["python --version", """python -c 'print(123)'"""] try: runner = CliRunner() @@ -37,6 +39,7 @@ def test_minify(): container.remove() +@pytest.mark.skip(reason="ptrace no longer supported under docker") def test_minify_abort(): client = docker.from_env() container = client.containers.run("python:3.9-slim", detach=True, tty=True) @@ -64,7 +67,7 @@ def test_minify_abort(): container.stop() container.remove() - +@pytest.mark.skip(reason="ptrace no longer supported under docker") def test_minify_with_mounted_volume(tmp_path: Path): client = docker.from_env() diff --git a/neurodocker/reproenv/tests/test_state.py b/neurodocker/reproenv/tests/test_state.py index 1bb97385..ba40d0bf 100644 --- a/neurodocker/reproenv/tests/test_state.py +++ b/neurodocker/reproenv/tests/test_state.py @@ -13,7 +13,7 @@ def test_validate_template_invalid_templates(): _validate_template({}) with pytest.raises( - exceptions.TemplateError, match="'binaries' is a required property" + exceptions.TemplateError, match="{'name': 'bar'} is not valid" ): _validate_template({"name": "bar"}) From 139a245a545511413a4e93867221f277b6f695e7 Mon Sep 17 00:00:00 2001 From: Satrajit Ghosh <satra@mit.edu> Date: Sat, 14 Jan 2023 15:43:07 -0500 Subject: [PATCH 3/3] fix flake --- neurodocker/cli/minify/tests/test_minify.py | 1 + 1 file changed, 1 insertion(+) diff --git a/neurodocker/cli/minify/tests/test_minify.py b/neurodocker/cli/minify/tests/test_minify.py index 9aa8c659..d129d71a 100644 --- a/neurodocker/cli/minify/tests/test_minify.py +++ b/neurodocker/cli/minify/tests/test_minify.py @@ -67,6 +67,7 @@ def test_minify_abort(): container.stop() container.remove() + @pytest.mark.skip(reason="ptrace no longer supported under docker") def test_minify_with_mounted_volume(tmp_path: Path): client = docker.from_env()