From 2b6d203ce1607981409d74ff4910a726bf7df605 Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Thu, 7 Mar 2024 22:22:53 +0100 Subject: [PATCH 1/4] fixed #17 --- .github/workflows/cli-coverage.yml | 40 ++++++++++++++++++++++++++++++ .github/workflows/run-codecov.yml | 38 ---------------------------- README.md | 32 ++++++++++++++++++++---- codecov.yml | 21 ---------------- pephubclient/__init__.py | 2 +- pephubclient/helpers.py | 11 +++++++- requirements/requirements-test.txt | 3 ++- setup.py | 2 +- 8 files changed, 81 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/cli-coverage.yml delete mode 100644 .github/workflows/run-codecov.yml delete mode 100644 codecov.yml diff --git a/.github/workflows/cli-coverage.yml b/.github/workflows/cli-coverage.yml new file mode 100644 index 0000000..8221d4a --- /dev/null +++ b/.github/workflows/cli-coverage.yml @@ -0,0 +1,40 @@ +name: test coverage + +on: + push: + branches: [master, dev] + +jobs: + cli-coverage-report: + strategy: + matrix: + python-version: [ "3.11" ] + os: [ ubuntu-latest ] + r: [ release ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v1 + with: + python-version: '3.10' + + - name: Install test dependencies + run: if [ -f requirements/requirements-dev.txt ]; then pip install -r requirements/requirements-test.txt; fi + + - run: pip install . + + - name: Run tests + run: coverage run -m pytest + + - name: build coverage + run: coverage html -i + + - run: smokeshow upload htmlcov + env: + SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage} + SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 80 + SMOKESHOW_GITHUB_CONTEXT: coverage + SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }} \ No newline at end of file diff --git a/.github/workflows/run-codecov.yml b/.github/workflows/run-codecov.yml deleted file mode 100644 index 364eb68..0000000 --- a/.github/workflows/run-codecov.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Run codecov - -on: - push: - branches: [dev] - pull_request: - branches: [master] - -jobs: - pytest: - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: [3.11] - os: [ubuntu-latest] - - steps: - - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install test dependencies - run: if [ -f requirements/requirements-test.txt ]; then pip install -r requirements/requirements-test.txt; fi - - - name: Install package - run: python -m pip install . - - - name: Run pytest tests - run: pytest tests --cov=./ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - file: ./coverage.xml - name: py-${{ matrix.python-version }}-${{ matrix.os }} \ No newline at end of file diff --git a/README.md b/README.md index 5e6f626..d76f2ef 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,36 @@ -# `PEPHubClient` +

PEPHubClient

[![PEP compatible](https://pepkit.github.io/img/PEP-compatible-green.svg)](https://pepkit.github.io) ![Run pytests](https://github.com/pepkit/pephubclient/workflows/Run%20pytests/badge.svg) -[![codecov](https://codecov.io/gh/pepkit/pephubclient/branch/dev/graph/badge.svg)](https://codecov.io/gh/pepkit/pephubclient) -[![pypi-badge](https://img.shields.io/pypi/v/pephubclient)](https://pypi.org/project/pephubclient) +[![pypi-badge](https://img.shields.io/pypi/v/pephubclient?color=%2334D058)](https://pypi.org/project/pephubclient) +[![pypi-version](https://img.shields.io/pypi/pyversions/pephubclient.svg?color=%2334D058)](https://pypi.org/project/pephubclient) +[![Coverage](https://coverage-badge.samuelcolvin.workers.dev/pepkit/pephubclient.svg)](https://coverage-badge.samuelcolvin.workers.dev/redirect/pepkit/pephubclient) +[![Github badge](https://img.shields.io/badge/source-github-354a75?logo=github)](https://github.com/pepkit/pephubclient) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) + `PEPHubClient` is a tool to provide Python API and CLI for [PEPhub](https://pephub.databio.org). -`pephubclient` features: + +--- + +**Documentation**: https://pep.databio.org + +**Source Code**: https://github.com/pepkit/pephubclient + +--- + +## Installation +To install `pepdbagent` use this command: +``` +pip install pephubclient +``` +or install the latest version from the GitHub repository: +``` +pip install git+https://github.com/pepkit/pephubclient.git +``` + +### `pephubclient` features: 1) `push` (upload) projects) 2) `pull` (download projects) @@ -17,7 +39,7 @@ The authorization process is based on pephub device authorization protocol. To upload projects or to download private projects, user must be authorized through pephub. If you want to use your own pephub instance, you can specify it by setting `PEPHUB_BASE_URL` environment variable. -e.g. `export PEPHUB_BASE_URL=https://pephub.databio.org` (This is original pephub instance) +e.g. `export PEPHUB_BASE_URL=https://pephub.databio.org/` (This is original pephub instance) To login, use the `login` argument; to logout, use `logout`. diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index f0e5c72..0000000 --- a/codecov.yml +++ /dev/null @@ -1,21 +0,0 @@ -ignore: - - "*/cli.py" - - "*/__main__.py" - - "*/__init__.py" - - "setup.py" - -coverage: - status: - project: - default: false # disable the default status that measures entire project - tests: - paths: - - "tests/" - target: 70% - source: - paths: - - "jupytext/" - target: 70% - patch: - default: - target: 70% \ No newline at end of file diff --git a/pephubclient/__init__.py b/pephubclient/__init__.py index 4cdf008..0c45462 100644 --- a/pephubclient/__init__.py +++ b/pephubclient/__init__.py @@ -4,7 +4,7 @@ import coloredlogs __app_name__ = "pephubclient" -__version__ = "0.4.0" +__version__ = "0.4.1" __author__ = "Oleksandr Khoroshevskyi, Rafal Stepien" diff --git a/pephubclient/helpers.py b/pephubclient/helpers.py index 85979bf..e2f53f4 100644 --- a/pephubclient/helpers.py +++ b/pephubclient/helpers.py @@ -37,7 +37,7 @@ def send_request( params: Optional[dict] = None, json: Optional[dict] = None, ) -> requests.Response: - return requests.request( + request_return = requests.request( method=method, url=url, verify=False, @@ -46,6 +46,15 @@ def send_request( params=params, json=json, ) + if request_return.status_code == 401: + if ( + RequestManager.decode_response(request_return, output_json=True).get( + "detail" + ) + == "JWT has expired" + ): + raise ResponseError("JWT has expired. Please log in again.") + return request_return @staticmethod def decode_response( diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index 241ddcd..d5878df 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -6,4 +6,5 @@ pytest-mock flake8 coveralls pytest-cov -pre-commit \ No newline at end of file +pre-commit +coverage \ No newline at end of file diff --git a/setup.py b/setup.py index cdf8165..0b83253 100644 --- a/setup.py +++ b/setup.py @@ -49,6 +49,7 @@ def read_reqs(reqs_name): keywords="project, bioinformatics, metadata", url=f"https://github.com/databio/{PACKAGE}/", author=AUTHOR, + author_email="khorosh@virginia.edu", license="BSD2", entry_points={ "console_scripts": [ @@ -56,7 +57,6 @@ def read_reqs(reqs_name): ], }, package_data={PACKAGE: ["templates/*"]}, - scripts=None, include_package_data=True, test_suite="tests", tests_require=read_reqs("test"), From 697bd9a36a28348b5250a2fda842b081a1d04b10 Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Thu, 7 Mar 2024 22:26:06 +0100 Subject: [PATCH 2/4] updated requirements --- README.md | 2 ++ requirements/requirements-test.txt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d76f2ef..42bf9e8 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ or install the latest version from the GitHub repository: pip install git+https://github.com/pepkit/pephubclient.git ``` +--- + ### `pephubclient` features: 1) `push` (upload) projects) 2) `pull` (download projects) diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index d5878df..ba8d468 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -7,4 +7,5 @@ flake8 coveralls pytest-cov pre-commit -coverage \ No newline at end of file +coverage +smokeshow From f0b6c76274eba4e9ec975e96d7fb56629271fb7f Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Thu, 7 Mar 2024 22:29:47 +0100 Subject: [PATCH 3/4] updated requirements2 --- .github/workflows/cli-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cli-coverage.yml b/.github/workflows/cli-coverage.yml index 8221d4a..5365a27 100644 --- a/.github/workflows/cli-coverage.yml +++ b/.github/workflows/cli-coverage.yml @@ -20,7 +20,7 @@ jobs: python-version: '3.10' - name: Install test dependencies - run: if [ -f requirements/requirements-dev.txt ]; then pip install -r requirements/requirements-test.txt; fi + run: if [ -f requirements/requirements-test.txt ]; then pip install -r requirements/requirements-test.txt; fi - run: pip install . From e10550c99523b6e6a4826b9bf5c625814f266aec Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Thu, 7 Mar 2024 22:33:58 +0100 Subject: [PATCH 4/4] changelog --- docs/changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index c0209da..71bbe7e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. +## [0.4.1] - 2024-03-07 +### Fixed +- Expired token error handling ([#17](https://github.com/pepkit/pephubclient/issues/17)) + ## [0.4.0] - 2024-02-12 ### Added - a parameter that points to where peps should be saved ([#32](https://github.com/pepkit/pephubclient/issues/32))