From 434973b6a21445626cf2da969e38c8f2d8bd63ce Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Wed, 11 Dec 2019 09:08:18 -0700 Subject: [PATCH 1/5] adding lint checker, and removing rule about ignoring export environment lines Signed-off-by: Vanessa Sochat --- .github/workflows/main.yml | 23 +++++++++++++++++++++++ CHANGELOG.md | 1 + spython/main/parse/parsers/singularity.py | 4 ++-- spython/version.py | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..caffe5d1 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,23 @@ +name: oci-python-ci + +on: + push: + branches: + - master + pull_request: + branches_ignore: [] + +jobs: + formatting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Setup black linter + run: conda create --quiet --name black black + + - name: Lint python code + run: | + export PATH="/usr/share/miniconda/bin:$PATH" + source activate black + black --check spython diff --git a/CHANGELOG.md b/CHANGELOG.md index 80917b29..acf467bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The client here will eventually be released as "spython" (and eventually to singularity on pypi), and the versions here will coincide with these releases. ## [master](https://github.com/singularityhub/singularity-cli/tree/master) + - export lines aren't ignored from environment, but replaced (0.0.75) - instance logging functions for Singularity 3.5 and up (0.0.74) - add sudo_options option to spython.main.Client.build (0.0.73) - list of options and writable added to shell, execute, and run (0.0.72) diff --git a/spython/main/parse/parsers/singularity.py b/spython/main/parse/parsers/singularity.py index 2e16bb5e..fefe650e 100644 --- a/spython/main/parse/parsers/singularity.py +++ b/spython/main/parse/parsers/singularity.py @@ -111,7 +111,7 @@ def _test(self, lines): def _env(self, lines): """env will parse a list of environment lines and simply remove any - blank lines, or those with export. Dockerfiles don't usually + blank lines, and exports. Dockerfiles don't usually have exports. Parameters @@ -119,7 +119,7 @@ def _env(self, lines): lines: A list of environment pair lines. """ - environ = [x for x in lines if not x.startswith("export")] + environ = [x.replace("export", "").strip() for x in lines] self.recipe.environ += environ # Files for container diff --git a/spython/version.py b/spython/version.py index b50fbda9..5cc036da 100644 --- a/spython/version.py +++ b/spython/version.py @@ -5,7 +5,7 @@ # with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -__version__ = "0.0.74" +__version__ = "0.0.75" AUTHOR = "Vanessa Sochat" AUTHOR_EMAIL = "vsochat@stanford.edu" NAME = "spython" From 1cee9fd606323a54036921aeac2867f642dc2205 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Wed, 11 Dec 2019 09:10:27 -0700 Subject: [PATCH 2/5] still need to ignore lonely exports without = Signed-off-by: Vanessa Sochat --- spython/main/parse/parsers/singularity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spython/main/parse/parsers/singularity.py b/spython/main/parse/parsers/singularity.py index fefe650e..554d1fbe 100644 --- a/spython/main/parse/parsers/singularity.py +++ b/spython/main/parse/parsers/singularity.py @@ -119,7 +119,7 @@ def _env(self, lines): lines: A list of environment pair lines. """ - environ = [x.replace("export", "").strip() for x in lines] + environ = [x.replace("export", "").strip() for x in lines if "=" in x] self.recipe.environ += environ # Files for container From 96ddbe2263d22690e5dc06c0e1a97836b7684210 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Wed, 11 Dec 2019 09:14:58 -0700 Subject: [PATCH 3/5] use re instead to get at beginning of line Signed-off-by: Vanessa Sochat --- spython/main/parse/parsers/singularity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spython/main/parse/parsers/singularity.py b/spython/main/parse/parsers/singularity.py index 554d1fbe..270e3df8 100644 --- a/spython/main/parse/parsers/singularity.py +++ b/spython/main/parse/parsers/singularity.py @@ -119,7 +119,7 @@ def _env(self, lines): lines: A list of environment pair lines. """ - environ = [x.replace("export", "").strip() for x in lines if "=" in x] + environ = [re.sub("^export", "", x).strip() for x in lines if "=" in x] self.recipe.environ += environ # Files for container From 21069944da36d11fd334f9346b5d159fe44ab156 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Wed, 11 Dec 2019 14:50:57 -0700 Subject: [PATCH 4/5] adding badge to readme Signed-off-by: Vanessa Sochat --- .github/workflows/main.yml | 2 +- README.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index caffe5d1..5cb6b75b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: oci-python-ci +name: spython-ci on: push: diff --git a/README.md b/README.md index b89b60c0..c213be1a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Singularity Python [![Build Status](https://travis-ci.org/singularityhub/singularity-cli.svg?branch=master)](https://travis-ci.org/singularityhub/singularity-cli) +[![GitHub actions status](https://github.com/singularityhub/singularity-cli/workflows/spython-ci/badge.svg?branch=master)](https://github.com/singularityhub/singularity-cli/actions?query=branch%3Amaster+workflow%3Aspython-ci) Singularity Python (spython) is the Python API for working with Singularity containers. See the [documentation](https://singularityhub.github.io/singularity-cli) for installation and usage, and From 0ce8d92f9763847f4f2e228612ca3e317d0c6ef9 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Wed, 11 Dec 2019 14:58:03 -0700 Subject: [PATCH 5/5] shub pulls not reliable given limits Signed-off-by: Vanessa Sochat --- spython/tests/test_client.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/spython/tests/test_client.py b/spython/tests/test_client.py index 6b5b2468..844960f1 100644 --- a/spython/tests/test_client.py +++ b/spython/tests/test_client.py @@ -29,19 +29,6 @@ def test_export(): shutil.rmtree(created_sandbox) -def test_pull_and_run(tmp_path): - pass - image = Client.pull("shub://vsoch/singularity-images", pull_folder=str(tmp_path)) - print(image) - assert os.path.exists(image) - ext = "sif" if Client.version_info().major >= 3 else "simg" - assert image == str(tmp_path / ("singularity-images." + ext)) - - result = Client.run(image) - print(result) - assert "You say please, but all I see is pizza.." in result - - def test_docker_pull(docker_container): tmp_path, container = docker_container print(container)