-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from wtsi-npg/devel
Release 0.2.0
- Loading branch information
Showing
9 changed files
with
187 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Referenced from: | ||
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot | ||
|
||
version: 2 | ||
updates: | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
# Change Log for npg_porch Project | ||
<!-- markdownlint-disable MD024 --> | ||
# Change Log for npg_porch_cli Project | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/). | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [Unreleased] | ||
## [0.2.0] - 2024-12-18 | ||
|
||
### Added | ||
|
||
* Added .github/dependabot.yml file to auto-update GitHub actions | ||
* Implemented the `create_token` action. Provided the caller has an admin token, | ||
this action generates and returns a new pipeline-specific token. | ||
* Used npg-python-lib to read Porch config | ||
|
||
## [0.1.0] - 2024-07-23 | ||
|
||
### Added | ||
|
||
# Initial project scaffold, code and tests | ||
* Initial project scaffold, code and tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from dataclasses import dataclass | ||
from os import R_OK, access | ||
from os.path import isfile | ||
|
||
from npg.conf import IniData | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class PorchClientConfig: | ||
""" | ||
Suggested config file content for interacting with a Porch server instance | ||
""" | ||
|
||
api_url: str | ||
pipeline_name: str | ||
pipeline_uri: str | ||
pipeline_version: str | ||
npg_porch_token: str | ||
|
||
|
||
def get_config_data( | ||
conf_file_path: str, conf_file_section: str = "PORCH" | ||
) -> PorchClientConfig: | ||
""" | ||
Parses a configuration file and returns its content. | ||
Args: | ||
conf_file_path: | ||
A configuration file with database connection details. | ||
conf_file_section: | ||
The section of the configuration file. Optional. Should be defined | ||
for 'ini' files. | ||
Returns: | ||
For an 'ini' file returns the content of the given section of the file as | ||
a dictionary. | ||
For a 'json' file, if the conf_file_section argument is not defined, the | ||
content of a file as a Python object is returned. If the conf_file_section | ||
argument is defined, the object returned by the parser is assumed to be | ||
a dictionary that has the value of the 'conf_file_section' argument as a key. | ||
The value corresponding to this key is returned. | ||
""" | ||
|
||
if isfile(conf_file_path) and access(conf_file_path, R_OK): | ||
porch_conf = IniData(PorchClientConfig).from_file( | ||
conf_file_path, conf_file_section | ||
) | ||
else: | ||
raise FileNotFoundError(f"{conf_file_path} is not present or cannot be read") | ||
|
||
return porch_conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[STUFF] | ||
|
||
logging = INFO | ||
|
||
[PORCH] | ||
|
||
api_url = https://porch.dnapipelines.sanger.ac.uk | ||
pipeline_name = test_pipeline | ||
pipeline_uri = https://test.pipeline.com | ||
pipeline_version = 9.9.9 | ||
npg_porch_token = 0123456789abcdef0123456789abcdef | ||
|
||
[PARTIALPORCH] | ||
|
||
api_url = https://porch.dnapipelines.sanger.ac.uk | ||
pipeline_name = test_pipeline | ||
pipeline_uri = https://test.pipeline.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from pytest import raises | ||
|
||
from npg_porch_cli.config import PorchClientConfig, get_config_data | ||
|
||
|
||
def test_conf_obj(): | ||
config_obj = get_config_data("tests/data/conf.ini") | ||
assert config_obj.pipeline_name == "test_pipeline" | ||
assert config_obj.pipeline_version == "9.9.9" | ||
|
||
assert type(config_obj) is PorchClientConfig | ||
|
||
with raises(FileNotFoundError, match="notafile is not present or cannot be read"): | ||
get_config_data("notafile", conf_file_section="ABSENT") | ||
|
||
with raises(TypeError, match="missing 2 required keyword-only arguments"): | ||
get_config_data("tests/data/conf.ini", conf_file_section="PARTIALPORCH") |