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

Release 0.2.1 #27

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
14 changes: 0 additions & 14 deletions .github/workflows/black.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/ruff_linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Ruff

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually switching to ruff for all projects? We should probably discuss (briefly) at the next Infrastructure meeting.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we're using black. don't switch this kind of thing please.

if you have a compelling case to switch, we should discuss, but then we'll switch all our projects.


on:
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
# Run the Ruff linter.
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.3
hooks:
# Run the Ruff linter.
- id: ruff
# Run the Ruff formatter.
- id: ruff-format
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
lint:
# black should be last in the list, as it lint the code. Tests can fail if order will be different
flake8 && isort . && black .
ruff format .

run-coverage:
coverage run -m pytest
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.1] - 2023-11-01
### Added
- is_registry_path checker function

## [0.2.0] - 2023-10-02
### Added
- Project search functionality
Expand Down
2 changes: 1 addition & 1 deletion pephubclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pephubclient.pephubclient import PEPHubClient

__app_name__ = "pephubclient"
__version__ = "0.2.0"
__version__ = "0.2.1"
__author__ = "Oleksandr Khoroshevskyi, Rafal Stepien"


Expand Down
19 changes: 19 additions & 0 deletions pephubclient/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import requests
from requests.exceptions import ConnectionError

from ubiquerg import parse_registry_path
from pydantic.error_wrappers import ValidationError

from pephubclient.exceptions import PEPExistsError, ResponseError
from pephubclient.constants import RegistryPath


class RequestManager:
Expand Down Expand Up @@ -84,3 +88,18 @@ def call_client_func(func: Callable[..., Any], **kwargs) -> Any:
MessageHandler.print_warning(f"PEP already exists. {err}")
except OSError as err:
MessageHandler.print_error(f"{err}")


def is_registry_path(input_string: str) -> bool:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something very similar exists in Looper. Should this, therefore, now be placed in ubiquerg along with parse_registry_path?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this should be part of pephubclient, and looper should now use this function

"""
Check if input is a registry path to pephub
:param str input_string: path to the PEP (or registry path)
:return bool: True if input is a registry path
"""
if input_string.endswith(".yaml"):
return False
try:
RegistryPath(**parse_registry_path(input_string))
except (ValidationError, TypeError):
return False
return True
1 change: 1 addition & 0 deletions requirements/requirements-all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ peppy>=0.35.7
requests>=2.28.2
pydantic<2.0
pandas>=2.0.0
ubiquerg>=0.6.3
4 changes: 3 additions & 1 deletion requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
black

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use ruff, can we remove black?

ruff
pytest
python-dotenv
pytest-mock
flake8
coveralls
pytest-cov
pytest-cov
pre-commit
45 changes: 44 additions & 1 deletion tests/test_pephubclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from pephubclient.exceptions import ResponseError
from pephubclient.pephubclient import PEPHubClient
from pephubclient.helpers import is_registry_path

SAMPLE_PEP = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
Expand Down Expand Up @@ -150,11 +151,53 @@ def test_push_with_pephub_error_response(

def test_search_prj(self, mocker):
return_value = b'{"count":1,"limit":100,"offset":0,"items":[{"namespace":"namespace1","name":"basic","tag":"default","is_private":false,"number_of_samples":2,"description":"None","last_update_date":"2023-08-27 19:07:31.552861+00:00","submission_date":"2023-08-27 19:07:31.552858+00:00","digest":"08cbcdbf4974fc84bee824c562b324b5","pep_schema":"random_schema_name"}],"session_info":null,"can_edit":false}'
requests_mock = mocker.patch(
mocker.patch(
"requests.request",
return_value=Mock(content=return_value, status_code=200),
)

return_value = PEPHubClient().find_project(namespace="namespace1")
assert return_value.count == 1
assert len(return_value.items) == 1


class TestHelpers:
@pytest.mark.parametrize(
"input_str, expected_output",
[
(
"databio/pep:default",
True,
),
(
"pephub.databio.org::databio/pep:default",
True,
),
(
"pephub.databio.org://databio/pep:default",
True,
),
(
"databio/pep",
True,
),
(
"databio/pep/default",
False,
),
(
"some/random/path/to.yaml",
False,
),
(
"path_to.csv",
False,
),
(
"this/is/path/to.csv",
False,
),
],
)
def test_is_registry_path(self, input_str, expected_output):
assert is_registry_path(input_str) is expected_output
Loading