Skip to content

Commit

Permalink
Merge pull request #31 from pepkit/dev
Browse files Browse the repository at this point in the history
v0.3.0  release
  • Loading branch information
khoroshevskyi authored Jan 17, 2024
2 parents fa51a20 + 16d734a commit 98c4a4d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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
6 changes: 5 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions pephubclient/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
10 changes: 5 additions & 5 deletions pephubclient/helpers.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")


Expand Down
9 changes: 3 additions & 6 deletions pephubclient/models.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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):
Expand All @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions pephubclient/pephubclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.")
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements-all.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 98c4a4d

Please sign in to comment.