From 202fe6ab14c4f0fb425d37d5e00ec3148c594a7c Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 28 Mar 2024 11:49:21 +0100 Subject: [PATCH 01/13] fix docker compose context --- repository-services/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repository-services/docker-compose.yml b/repository-services/docker-compose.yml index 073f68f..c1d7683 100644 --- a/repository-services/docker-compose.yml +++ b/repository-services/docker-compose.yml @@ -2,12 +2,12 @@ version: '3' services: isa_biosamples: - build: ./repository-testservers/isajson-biosamples + build: isajson-biosamples ports: - "8032:8032" isa_sra: - build: ./repository-testservers/isajson-ena + build: isajson-ena ports: - "8042:8042" From 67979805dc12b4a9fbd53b3814119c85a8f54a66 Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 28 Mar 2024 11:50:32 +0100 Subject: [PATCH 02/13] bundle test dependencies in setup.py --- mars-cli/requirements.txt | 3 +-- mars-cli/setup.py | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mars-cli/requirements.txt b/mars-cli/requirements.txt index 7aaac6a..61f29b3 100644 --- a/mars-cli/requirements.txt +++ b/mars-cli/requirements.txt @@ -1,3 +1,2 @@ requests -jsonschema -pytest \ No newline at end of file +jsonschema \ No newline at end of file diff --git a/mars-cli/setup.py b/mars-cli/setup.py index 8f20e8b..69c1ffd 100644 --- a/mars-cli/setup.py +++ b/mars-cli/setup.py @@ -18,6 +18,15 @@ version=__version__, license="MIT", install_requires=[required_deps], + extras_require={ + "test": [ + # Dependencies for testing only + "black", + "ruff", + "pytest", + "pytest-cov", + ] + }, project_urls={ "Source": "https://github.com/elixir-europe/MARS", "Bug Reports": "https://github.com/elixir-europe/MARS/issues", From 84e6ab99b131c1a09dcadd9ed2f5595fe74e2f4d Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 28 Mar 2024 11:51:41 +0100 Subject: [PATCH 03/13] Fix workflow --- .github/workflows/test-mars.yml | 65 ++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/.github/workflows/test-mars.yml b/.github/workflows/test-mars.yml index 90159af..9f432a3 100644 --- a/.github/workflows/test-mars.yml +++ b/.github/workflows/test-mars.yml @@ -1,36 +1,43 @@ name: Test MARS on: - pull_request: - paths: - -'mars-cli/**' + push: + paths: + - "mars-cli/**" + pull_request: + paths: + - "mars-cli/**" + branches: + - main + workflow_dispatch: jobs: - test-mars: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + test-mars: + runs-on: ubuntu-latest + env: + working-directory: ./mars-cli + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip setuptools wheel - pip install -r requirements.txt - pip install black - pip install ruff - - - name: Test python code - run: pytest --doctest-modules --cov=mars_lib tests/ --cov-fail-under=80 + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: '**/setup.py' + - run: pip install -e '.[test]' + working-directory: ${{ env.working-directory }} + + - name: Test python code + run: pytest --doctest-modules --cov=mars_lib tests/ --cov-fail-under=80 + working-directory: ${{ env.working-directory }} - - name: Formatting - run: black --check mars_lib/ + - name: Formatting + run: black --check mars_lib/ + working-directory: ${{ env.working-directory }} - - name: Linting - run: ruff check mars_lib/ + - name: Linting + run: ruff check mars_lib/ + working-directory: ${{ env.working-directory }} From 578955edfde98876d761fd4a47b9f0c0016ab52b Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 28 Mar 2024 12:11:37 +0100 Subject: [PATCH 04/13] Add installing instructions --- mars-cli/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mars-cli/README.md b/mars-cli/README.md index b602705..972a85c 100644 --- a/mars-cli/README.md +++ b/mars-cli/README.md @@ -1,3 +1,18 @@ +# Installing the mars-cli + +Installing the mars-cli from source: + +```sh +cd mars-cli # Assuming you are in the root folder +pip install . +``` + +If you want to install the optional testing dependencies as well, useful when contributing to the project: + +```sh +pip install -e '.[test]' +``` + # Extending BioSamples' records The Python script ``biosamples-externalReferences.py`` defines a class BiosamplesRecord for managing biosample records. This class is designed to interact with the BioSamples database, allowing operations like fetching, updating, and extending biosample records. The script takes in a dictionary of BioSamples' accessions and their associated external references, and expands the former with the latter. From 29653bd3b6b2dcf1eee617556f40fdba683392ab Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 28 Mar 2024 16:44:47 +0100 Subject: [PATCH 05/13] simplify test command --- mars-cli/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mars-cli/README.md b/mars-cli/README.md index 972a85c..a34a12d 100644 --- a/mars-cli/README.md +++ b/mars-cli/README.md @@ -10,7 +10,7 @@ pip install . If you want to install the optional testing dependencies as well, useful when contributing to the project: ```sh -pip install -e '.[test]' +pip install .[test] ``` # Extending BioSamples' records From 52952d51c4e9041e3e563fce288aa1dabb278ffa Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 28 Mar 2024 20:40:34 +0100 Subject: [PATCH 06/13] remove deprecated version and add restart constraints --- repository-services/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repository-services/docker-compose.yml b/repository-services/docker-compose.yml index c1d7683..3102ecd 100644 --- a/repository-services/docker-compose.yml +++ b/repository-services/docker-compose.yml @@ -1,13 +1,13 @@ -version: '3' - services: isa_biosamples: build: isajson-biosamples ports: - "8032:8032" + restart: unless-stopped isa_sra: build: isajson-ena ports: - "8042:8042" + restart: unless-stopped From 3f9980949692844ebf2d4f4ead3227e69ac76fe4 Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Fri, 29 Mar 2024 14:18:13 +0100 Subject: [PATCH 07/13] Make pytest more configurable --- .github/workflows/test-mars.yml | 2 +- mars-cli/.coveragerc | 2 ++ mars-cli/pytest.ini | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 mars-cli/.coveragerc create mode 100644 mars-cli/pytest.ini diff --git a/.github/workflows/test-mars.yml b/.github/workflows/test-mars.yml index 9f432a3..7471373 100644 --- a/.github/workflows/test-mars.yml +++ b/.github/workflows/test-mars.yml @@ -31,7 +31,7 @@ jobs: working-directory: ${{ env.working-directory }} - name: Test python code - run: pytest --doctest-modules --cov=mars_lib tests/ --cov-fail-under=80 + run: pytest working-directory: ${{ env.working-directory }} - name: Formatting diff --git a/mars-cli/.coveragerc b/mars-cli/.coveragerc new file mode 100644 index 0000000..4667a72 --- /dev/null +++ b/mars-cli/.coveragerc @@ -0,0 +1,2 @@ +[run] +omit = mars_lib/__init__.py, mars_lib/submit.py diff --git a/mars-cli/pytest.ini b/mars-cli/pytest.ini new file mode 100644 index 0000000..b20ef45 --- /dev/null +++ b/mars-cli/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --doctest-modules --cov=mars_lib tests/ --cov-fail-under=80 \ No newline at end of file From e5c2d233f39f219a7916dc5f3de738788e74bd0d Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Fri, 29 Mar 2024 14:26:01 +0100 Subject: [PATCH 08/13] add tests for windows --- .github/workflows/test-mars.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-mars.yml b/.github/workflows/test-mars.yml index 7471373..0f16d39 100644 --- a/.github/workflows/test-mars.yml +++ b/.github/workflows/test-mars.yml @@ -12,12 +12,13 @@ on: jobs: test-mars: - runs-on: ubuntu-latest - env: - working-directory: ./mars-cli strategy: matrix: + os: [ubuntu-latest, windows-latest] python-version: ["3.9", "3.10", "3.11", "3.12"] + runs-on: ${{ matrix.os }} + env: + working-directory: ./mars-cli steps: - uses: actions/checkout@v4 From 0e4d748a2e8bbf02e132a816db37e15909c300c2 Mon Sep 17 00:00:00 2001 From: bedroesb Date: Wed, 10 Apr 2024 15:55:44 +0200 Subject: [PATCH 09/13] adding newlines --- mars-cli/README.md | 2 +- mars-cli/pytest.ini | 2 +- mars-cli/requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mars-cli/README.md b/mars-cli/README.md index a34a12d..6a816c0 100644 --- a/mars-cli/README.md +++ b/mars-cli/README.md @@ -142,4 +142,4 @@ public class BiosamplesIntegration { // Handle other operations similarly } } -```` \ No newline at end of file +```` diff --git a/mars-cli/pytest.ini b/mars-cli/pytest.ini index b20ef45..987643d 100644 --- a/mars-cli/pytest.ini +++ b/mars-cli/pytest.ini @@ -1,2 +1,2 @@ [pytest] -addopts = --doctest-modules --cov=mars_lib tests/ --cov-fail-under=80 \ No newline at end of file +addopts = --doctest-modules --cov=mars_lib tests/ --cov-fail-under=80 diff --git a/mars-cli/requirements.txt b/mars-cli/requirements.txt index 61f29b3..cbfb8e1 100644 --- a/mars-cli/requirements.txt +++ b/mars-cli/requirements.txt @@ -1,2 +1,2 @@ requests -jsonschema \ No newline at end of file +jsonschema From d8f0dad74811f011d9d6a1fdbafb5f281d6c9e43 Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 11 Apr 2024 08:01:52 +0200 Subject: [PATCH 10/13] exclude credential.py from coverage calculation --- mars-cli/.coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mars-cli/.coveragerc b/mars-cli/.coveragerc index 4667a72..2c3ba72 100644 --- a/mars-cli/.coveragerc +++ b/mars-cli/.coveragerc @@ -1,2 +1,2 @@ [run] -omit = mars_lib/__init__.py, mars_lib/submit.py +omit = mars_lib/__init__.py, mars_lib/submit.py, mars_lib/credential.py From 4acbbf319160c09636244911ea562dfa39f9bd01 Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 11 Apr 2024 08:05:37 +0200 Subject: [PATCH 11/13] reformat credential.py --- mars-cli/mars_lib/credential.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mars-cli/mars_lib/credential.py b/mars-cli/mars_lib/credential.py index a62306a..2fcb23d 100644 --- a/mars-cli/mars_lib/credential.py +++ b/mars-cli/mars_lib/credential.py @@ -50,6 +50,7 @@ print(keyring.get_keyring()) # keyring.backends.SecretService.Keyring (priority: 5) + class CredentialManager: def __init__(self, service_name): self.service_name = service_name @@ -57,7 +58,7 @@ def __init__(self, service_name): def get_credential_env(self, username): """ Retrieves a credential from environment variables. - + :param username: The environment variable username. :return: The value of the environment variable or None if not found. """ @@ -66,7 +67,7 @@ def get_credential_env(self, username): def prompt_for_password(self): """ Securely prompts the user to enter a password in the console. - + :return: The password entered by the user. """ return getpass.getpass(prompt="Enter your password: ") @@ -74,7 +75,7 @@ def prompt_for_password(self): def set_password_keyring(self, username, password): """ Stores a password in the keyring under the given username. - + :param username: The username associated with the password. :param password: The password to store. """ @@ -83,7 +84,7 @@ def set_password_keyring(self, username, password): def get_password_keyring(self, username): """ Retrieves a password from the keyring for the given username. - + :param username: The username whose password to retrieve. :return: The password or None if not found. """ @@ -92,8 +93,7 @@ def get_password_keyring(self, username): def delete_password_keyring(self, username): """ Deletes a password from the keyring for the given username. - + :param username: The username whose password to delete. """ keyring.delete_password(self.service_name, username) - From 5d854fcf19491a1c4b85fbc14dee0f1c0303177f Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 11 Apr 2024 08:10:50 +0200 Subject: [PATCH 12/13] Add keyring to requirements --- mars-cli/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/mars-cli/requirements.txt b/mars-cli/requirements.txt index cbfb8e1..bd4c238 100644 --- a/mars-cli/requirements.txt +++ b/mars-cli/requirements.txt @@ -1,2 +1,3 @@ requests jsonschema +keyring \ No newline at end of file From ce987e3548d80a2d235845d639a04596acf608bc Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Thu, 11 Apr 2024 08:12:45 +0200 Subject: [PATCH 13/13] Move import statement to the top of the document. Fixes linter error --- mars-cli/mars_lib/credential.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mars-cli/mars_lib/credential.py b/mars-cli/mars_lib/credential.py index 2fcb23d..333c4c1 100644 --- a/mars-cli/mars_lib/credential.py +++ b/mars-cli/mars_lib/credential.py @@ -1,6 +1,7 @@ import keyring import os import getpass +import keyring.util.platform_ as keyring_platform """ Credential Manager Module @@ -42,7 +43,6 @@ # Don't forget to handle exceptions and secure your credentials properly. """ -import keyring.util.platform_ as keyring_platform print(keyring_platform.config_root()) # /home/username/.config/python_keyring # Might be different for you