Skip to content

Commit

Permalink
fixed #17
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Mar 7, 2024
1 parent c71a4af commit 2b6d203
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 68 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/cli-coverage.yml
Original file line number Diff line number Diff line change
@@ -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 }}
38 changes: 0 additions & 38 deletions .github/workflows/run-codecov.yml

This file was deleted.

32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
# `PEPHubClient`
<h1 align="center">PEPHubClient</h1>

[![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**: <a href="https://pep.databio.org/" target="_blank">https://pep.databio.org</a>

**Source Code**: <a href="https://github.com/pepkit/pephubclient" target="_blank">https://github.com/pepkit/pephubclient</a>

---

## 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)

Expand All @@ -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`.

Expand Down
21 changes: 0 additions & 21 deletions codecov.yml

This file was deleted.

2 changes: 1 addition & 1 deletion pephubclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import coloredlogs

__app_name__ = "pephubclient"
__version__ = "0.4.0"
__version__ = "0.4.1"
__author__ = "Oleksandr Khoroshevskyi, Rafal Stepien"


Expand Down
11 changes: 10 additions & 1 deletion pephubclient/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion requirements/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pytest-mock
flake8
coveralls
pytest-cov
pre-commit
pre-commit
coverage
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def read_reqs(reqs_name):
keywords="project, bioinformatics, metadata",
url=f"https://github.com/databio/{PACKAGE}/",
author=AUTHOR,
author_email="[email protected]",
license="BSD2",
entry_points={
"console_scripts": [
"phc = pephubclient.__main__:main",
],
},
package_data={PACKAGE: ["templates/*"]},
scripts=None,
include_package_data=True,
test_suite="tests",
tests_require=read_reqs("test"),
Expand Down

0 comments on commit 2b6d203

Please sign in to comment.