Skip to content

Commit

Permalink
updated view creation
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Apr 16, 2024
1 parent e10550c commit 8317c8d
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

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.2] - 2024-04-16
### Updated
- View creation, by adding description and no_fail flag


## [0.4.1] - 2024-03-07
### Fixed
- Expired token error handling ([#17](https://github.com/pepkit/pephubclient/issues/17))
Expand Down
6 changes: 6 additions & 0 deletions docs/templates/usage.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Usage reference

pephubclient is a command line tool that can be used to interact with the PEPhub API.
It can be used to create, update, delete PEPs in the PEPhub database.

Below are usage examples for the different commands that can be used with pephubclient.
65 changes: 65 additions & 0 deletions docs/usage.md

Large diffs are not rendered by default.

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.1"
__version__ = "0.4.2"
__author__ = "Oleksandr Khoroshevskyi, Rafal Stepien"


Expand Down
2 changes: 1 addition & 1 deletion pephubclient/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def send_request(
headers: Optional[dict] = None,
cookies: Optional[dict] = None,
params: Optional[dict] = None,
json: Optional[dict] = None,
json: Optional[Union[dict, list]] = None,
) -> requests.Response:
request_return = requests.request(
method=method,
Expand Down
9 changes: 9 additions & 0 deletions pephubclient/modules/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,25 @@ def create(
name: str,
tag: str,
view_name: str,
description: str = None,
sample_list: list = None,
no_fail: bool = False,
):
"""
Create view in project in PEPhub.
:param namespace: namespace of project
:param name: name of project
:param tag: tag of project
:param description: description of the view
:param view_name: name of the view
:param sample_list: list of sample names
:param no_fail: whether to raise an error if view was not added to the project
"""

if not sample_list or not isinstance(sample_list, list):
raise ValueError("Sample list must be a list of sample names.")

url = self._build_view_request_url(
namespace=namespace, name=name, view_name=view_name
)
Expand All @@ -92,6 +100,7 @@ def create(
method="POST",
url=url,
headers=self.parse_header(self.__jwt_data),
params={"description": description, "no_fail": no_fail},
json=sample_list,
)
if response.status_code == ResponseStatusCodes.ACCEPTED:
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ coveralls
pytest-cov
pre-commit
coverage
smokeshow
smokeshow
21 changes: 21 additions & 0 deletions scripts/update_usage_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
cp ../docs/templates/usage.template usage.template

for cmd in "--help" "pull --help" "push --help"; do
echo $cmd
echo -e "## \`phc $cmd\`" > USAGE_header.temp
phc $cmd --help > USAGE.temp 2>&1
# sed -i 's/^/\t/' USAGE.temp
sed -i.bak '1s;^;\`\`\`console\
;' USAGE.temp
# sed -i '1s/^/\n\`\`\`console\n/' USAGE.temp
echo -e "\`\`\`\n" >> USAGE.temp
#sed -i -e "/\`looper $cmd\`/r USAGE.temp" -e '$G' usage.template # for -in place inserts
cat USAGE_header.temp USAGE.temp >> usage.template # to append to the end
done
rm USAGE.temp
rm USAGE_header.temp
rm USAGE.temp.bak
mv usage.template ../docs/usage.md
#cat usage.template
# rm USAGE.temp

0 comments on commit 8317c8d

Please sign in to comment.