diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 4e1ef42..b120129 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,6 +1,3 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - name: Upload Python Package on: @@ -9,9 +6,10 @@ on: jobs: deploy: - + name: upload release to PyPI runs-on: ubuntu-latest - + permissions: + id-token: write steps: - uses: actions/checkout@v2 - name: Set up Python @@ -23,9 +21,7 @@ jobs: python -m pip install --upgrade pip pip install setuptools wheel twine - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | python setup.py sdist bdist_wheel - twine upload dist/* + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/docs/changelog.md b/docs/changelog.md index be7aa7e..e2bb29a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,10 +2,14 @@ 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.2] - 2024-01-06 +## [0.3.0] - 2024-01-17 ### Added - customization of the base pephub URL. [#22](https://github.com/pepkit/pephubclient/issues/22) +### Updated +- PEPhub API URL +- Increased the required pydantic version to >2.5.0 + ## [0.2.1] - 2023-11-01 ### Added - is_registry_path checker function diff --git a/pephubclient/constants.py b/pephubclient/constants.py index 0c4a79f..e36e66a 100644 --- a/pephubclient/constants.py +++ b/pephubclient/constants.py @@ -2,10 +2,11 @@ from typing import Optional import os -import pydantic -from pydantic import BaseModel +from pydantic import BaseModel, field_validator -PEPHUB_BASE_URL = os.getenv("PEPHUB_BASE_URL", default="https://pephub.databio.org/") +PEPHUB_BASE_URL = os.getenv( + "PEPHUB_BASE_URL", default="https://pephub-api.databio.org/" +) # PEPHUB_BASE_URL = "http://0.0.0.0:8000/" PEPHUB_PEP_API_BASE_URL = f"{PEPHUB_BASE_URL}api/v1/projects/" PEPHUB_PEP_SEARCH_URL = f"{PEPHUB_BASE_URL}api/v1/namespaces/{{namespace}}/projects" @@ -19,7 +20,7 @@ class RegistryPath(BaseModel): subitem: Optional[str] tag: Optional[str] = "default" - @pydantic.validator("tag") + @field_validator("tag") def tag_should_not_be_none(cls, v): return v or "default" diff --git a/pephubclient/helpers.py b/pephubclient/helpers.py index 467a8dd..41f06e9 100644 --- a/pephubclient/helpers.py +++ b/pephubclient/helpers.py @@ -1,11 +1,11 @@ import json -from typing import Any, Callable, NoReturn, Optional +from typing import Any, Callable, Optional import requests from requests.exceptions import ConnectionError from ubiquerg import parse_registry_path -from pydantic.error_wrappers import ValidationError +from pydantic import ValidationError from pephubclient.exceptions import PEPExistsError, ResponseError from pephubclient.constants import RegistryPath @@ -57,15 +57,15 @@ class MessageHandler: GREEN = 40 @staticmethod - def print_error(text: str) -> NoReturn: + def print_error(text: str) -> None: print(f"\033[38;5;9m{text}\033[0m") @staticmethod - def print_success(text: str) -> NoReturn: + def print_success(text: str) -> None: print(f"\033[38;5;40m{text}\033[0m") @staticmethod - def print_warning(text: str) -> NoReturn: + def print_warning(text: str) -> None: print(f"\033[38;5;11m{text}\033[0m") diff --git a/pephubclient/models.py b/pephubclient/models.py index 07a92ba..b4a0172 100644 --- a/pephubclient/models.py +++ b/pephubclient/models.py @@ -1,8 +1,7 @@ import datetime from typing import Optional, List -import pydantic -from pydantic import BaseModel, Extra, Field +from pydantic import BaseModel, Field, field_validator, ConfigDict from peppy.const import CONFIG_KEY, SUBSAMPLE_RAW_LIST_KEY, SAMPLE_RAW_DICT_KEY @@ -15,9 +14,7 @@ class ProjectDict(BaseModel): subsample_list: Optional[list] = Field(alias=SUBSAMPLE_RAW_LIST_KEY) sample_list: list = Field(alias=SAMPLE_RAW_DICT_KEY) - class Config: - allow_population_by_field_name = True - extra = Extra.allow + model_config = ConfigDict(populate_by_name=True, extra="allow") class ProjectUploadData(BaseModel): @@ -30,7 +27,7 @@ class ProjectUploadData(BaseModel): is_private: Optional[bool] = False overwrite: Optional[bool] = False - @pydantic.validator("tag") + @field_validator("tag") def tag_should_not_be_none(cls, v): return v or "default" diff --git a/pephubclient/pephubclient.py b/pephubclient/pephubclient.py index 9eb6b8c..118bdd2 100644 --- a/pephubclient/pephubclient.py +++ b/pephubclient/pephubclient.py @@ -13,7 +13,7 @@ ) import requests import urllib3 -from pydantic.error_wrappers import ValidationError +from pydantic import ValidationError from ubiquerg import parse_registry_path from pephubclient.constants import ( @@ -170,7 +170,7 @@ def upload( method="POST", url=self._build_push_request_url(namespace=namespace), headers=self._get_header(jwt_data), - json=upload_data.dict(), + json=upload_data.model_dump(), cookies=None, ) if pephub_response.status_code == ResponseStatusCodes.ACCEPTED: @@ -345,7 +345,7 @@ def _load_raw_pep( correct_proj_dict = ProjectDict(**json.loads(decoded_response)) # This step is necessary because of this issue: https://github.com/pepkit/pephub/issues/124 - return correct_proj_dict.dict(by_alias=True) + return correct_proj_dict.model_dump(by_alias=True) if pephub_response.status_code == ResponseStatusCodes.NOT_EXIST: raise ResponseError("File does not exist, or you are unauthorized.") diff --git a/requirements/requirements-all.txt b/requirements/requirements-all.txt index 8163295..e091589 100644 --- a/requirements/requirements-all.txt +++ b/requirements/requirements-all.txt @@ -1,6 +1,6 @@ typer>=0.7.0 -peppy>=0.35.7 +peppy>=0.40.0 requests>=2.28.2 -pydantic<2.0 +pydantic>2.5.0 pandas>=2.0.0 ubiquerg>=0.6.3 \ No newline at end of file