Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create release 0.1.0 #13

Merged
merged 37 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d0045af
Added standard project files
mgcam Apr 19, 2024
c61f59e
Initial project scaffold
mgcam Apr 19, 2024
a5e9dbd
Merge pull request #1 from mgcam/devel
nerdstrike Apr 24, 2024
48d2abc
Run code checkers in CI
mgcam Apr 24, 2024
0d2b1c7
Merge pull request #3 from mgcam/more_ci
nerdstrike Apr 24, 2024
675c895
Imported a client script from GitLab.
jenniferliddle Jun 14, 2022
9e6b1da
Renamed and reformatted the imported script.
mgcam Apr 24, 2024
aa594ee
Manage flake8 via pyproject-flake8
mgcam Apr 25, 2024
3d0a05d
Reduced max line length to 88.
mgcam Apr 25, 2024
b5e1a4d
The bugbear returns.
mgcam Apr 25, 2024
70ffc5b
Merge pull request #4 from mgcam/copy_script_from_gitlab_project
nerdstrike Apr 25, 2024
59bef42
Created porch client API.
mgcam Apr 26, 2024
31a3e72
Streamlined handling of CA certificates
mgcam Apr 30, 2024
c7baaa1
On the client API level represent the task as a dict.
mgcam Apr 30, 2024
0bd5229
Validate status against porch OpenAPI schema
mgcam May 1, 2024
91ce087
Add instructions about the tokens
mgcam May 3, 2024
85ae282
Get list of valid actions from the API
mgcam May 3, 2024
e4e039e
Merge pull request #5 from mgcam/client_api
nerdstrike May 3, 2024
2ac7110
API refactored to consolidate the logic about the action.
mgcam May 3, 2024
324e27a
Removed duplication in listing valid actions
mgcam May 7, 2024
f55e97c
Use suitable native Python Exception types.
mgcam May 8, 2024
53c2dfd
Merge pull request #7 from mgcam/refactor
nerdstrike May 14, 2024
e098960
Renamed _send_request to send_request
mgcam Jun 26, 2024
7a58128
Simplified import of send_request
mgcam Jun 28, 2024
6e1d71b
Merge pull request #8 from mgcam/send_request2public
nerdstrike Jun 28, 2024
11c0014
Tweaked and tested send_request method.
mgcam Jul 8, 2024
da55dd7
Documented the functions
mgcam Jul 9, 2024
3935de0
Merge pull request #9 from mgcam/optional_auth
nerdstrike Jul 9, 2024
8e3d429
Expanded error message when possible
mgcam Jul 16, 2024
03ed48d
Added a trailing slash to url to avoid a redirect
mgcam Jul 16, 2024
81caf84
Formatted import
mgcam Jul 16, 2024
5fe758f
Merge pull request #10 from mgcam/extend_error_message
nerdstrike Jul 16, 2024
9d45a44
Explicitly set the status of the new task.
mgcam Jul 17, 2024
d8a3d81
Merge pull request #11 from mgcam/explicit_pending_status
nerdstrike Jul 18, 2024
9a53865
Updated documentation
mgcam Jul 18, 2024
c9e43a7
Prepared for release 0.1.0
mgcam Jul 23, 2024
55a6dfc
Merge pull request #12 from mgcam/prep_for_release
nerdstrike Jul 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will install Python dependencies and run tests
name: Python application

on:
push:
branches: [master, devel]
pull_request:
branches: [master, devel]

jobs:

test-packaging:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Poetry
run: |
pipx install poetry

- uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: 'x64'

- name: Run poetry install
run: |
poetry env use '3.11'
poetry install

- name: Run pytest
run: |
poetry run pytest

- name: Run import checker
run: |
poetry run isort --check .

- name: Run code style checker
run: |
poetry run pflake8

- name: Run code formatter
run: |
poetry run black --check src tests
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
*~
__pycache__
*.egg-info
.vscode
.eggs
build
.pytest_cache
.vscode
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Change Log for npg_porch Project

The format is based on [Keep a Changelog](http://keepachangelog.com/).
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.1.0] - 2024-07-23

### Added

# Initial project scaffold, code and tests
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,67 @@
# npg_porch_cli
A command-line client to enable communication with the npg_porch API.

A command-line client and a simple client library to enable communication
with the [npg_porch](https://github.com/wtsi-npg/npg_porch) JSON API.

Provides a Python script, `npg_porch_client`, and a Python client API.

NPG_PORCH_TOKEN environment variable should be set to the value of either
the admin or project-specific token. The token should be pre-registered in
the database that is used by the `porch` API server.

The project can be deployed with pip or poetry in a standard way.

Example of using a client API:

``` python
from npg_porch_cli.api import PorchRequest

pr = PorchRequest(porch_url="https://myporch.com")
response = pr.send(action="list_pipelines")

pr = PorchRequest(
porch_url="https://myporch.com",
pipeline_name="Snakemake_Cardinal",
pipeline_url="https://github.com/wtsi-npg/snakemake_cardinal",
pipeline_version="1.0",
)
response = pr.send(
action="update_task",
task_status="FAILED",
task_input={"id_run": 409, "sample": "Valxxxx", "id_study": "65"},
)
```

By default the client validates the certificate of the server's certification
authority (CA). If the server's certificate is signed by a custom CA, set the
`SSL_CERT_FILE` environment variable to the path of the CA's certificate.
Python versions starting from 3.11 seem to have increased security precautions
when validating certificates of custom CAs. It might be necessary to set the
`REQUESTS_CA_BUNDLE` environmental variable, see details
[here](https://requests.readthedocs.io/en/latest/user/advanced/#ssl-cert-verification).

``` bash
export NPG_PORCH_TOKEN='my_token'
export SSL_CERT_FILE=/path_to/my.pem
npg_porch_client list_pipelines --base_url https://myporch.com
```

It is possible, but not recommended, to disable this validation check.

``` bash
export NPG_PORCH_TOKEN='my_token'
npg_porch_client list_pipelines --base_url https://myporch.com --no-validate_ca_cert
```

A valid JSON string is required for the `--task_json` script's argument, note
double quotes in the example below.

``` bash
export NPG_PORCH_TOKEN='my_token'
npg_porch_client update_task --base_url https://myporch.com \
--pipeline Snakemake_Cardinal \
--pipeline_url 'https://github.com/wtsi-npg/snakemake_cardinal' \
--pipeline_version 1.0 \
--task_json '{"id_run": 409, "sample": "Valxxxx", "id_study": "65"}' \
--status FAILED
```
55 changes: 55 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[tool.poetry]
name = "npg_porch_cli"
version = "0.1.0"
authors = [
"Marina Gourtovaia",
"Kieron Taylor",
"Jennifer Liddle",
]
description = "CLI client for communicating with npg_porch JSON API"
readme = "README.md"
license = "GPL-3.0-or-later"

[tool.poetry.scripts]
npg_porch_client = "npg_porch_cli.api_cli_user:run"

[tool.poetry.dependencies]
python = "^3.10"
requests = "^2.31.0"

[tool.poetry.dev-dependencies]
black = "^22.3.0"
pyproject-flake8 = "^7.0.0"
flake8-bugbear = "^24.4.0"
pytest = "^7.1.1"
isort = { version = "^5.10.1", extras = ["colors"] }

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"

[tool.black]
line_length = 88

[tool.flake8]
max-line-length = 88
extend-select = ["B950"]
extend-ignore = ["E501"]
exclude = [
# No need to traverse our git directory
".git",
# There's no value in checking cache directories
"__pycache__"
]
per-file-ignores = """
# Disable 'imported but unused'
__init__.py: F401
"""

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]
1 change: 1 addition & 0 deletions src/npg_porch_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .api import send_request
Loading