Skip to content

Commit 6ece716

Browse files
committedMar 20, 2023
added setup, license, requirements
1 parent 2600c09 commit 6ece716

18 files changed

+94
-43
lines changed
 

‎LICENSE.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright 2023 Nathan Sheffield
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

‎MANIFEST.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include requirements/*
2+
include README.md
3+
include pephubclient/pephub_oauth/*

‎error_handling/constants.py

-7
This file was deleted.

‎error_handling/error_handler.py

-16
This file was deleted.

‎error_handling/models.py

-6
This file was deleted.

‎pephubclient/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__app_name__ = "pephubclient"
22
__version__ = "0.1.0"
3+
__author__ = "Oleksandr Khoroshevskyi, Rafal Stepien"
34

4-
5-
__all__ = ["__app_name__", "__version__"]
5+
__all__ = ["__app_name__", "__version__", "__author__"]

‎pephubclient/constants.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Optional
2-
2+
from enum import Enum
33
from pydantic import BaseModel
44

55
# PEPHUB_BASE_URL = "https://pephub.databio.org/"
@@ -15,3 +15,9 @@ class RegistryPath(BaseModel):
1515
item: str
1616
subitem: Optional[str]
1717
tag: Optional[str]
18+
19+
20+
class ResponseStatusCodes(int, Enum):
21+
FORBIDDEN_403 = 403
22+
NOT_EXIST_404 = 404
23+
OK_200 = 200

‎pephubclient/error_handler.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Here should be error handler
2+
File renamed without changes.

‎pephubclient/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import requests
55

6-
from error_handling.exceptions import ResponseError
6+
from pephubclient.exceptions import ResponseError
77

88

99
class RequestManager:

‎pephubclient/pephubclient.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
PEPHUB_BASE_URL,
1212
PEPHUB_PEP_API_BASE_URL,
1313
RegistryPath,
14+
ResponseStatusCodes
1415
)
1516
from pephubclient.models import JWTDataResponse
1617
from pephubclient.models import ClientData
17-
# from error_handling.exceptions import ResponseError, IncorrectQueryStringError
18-
# from error_handling.constants import ResponseStatusCodes
1918
from pephubclient.files_manager import FilesManager
2019
from pephubclient.helpers import RequestManager
2120

@@ -109,10 +108,10 @@ def _load_pep(
109108
def _handle_pephub_response(pephub_response: requests.Response):
110109
decoded_response = PEPHubClient.decode_response(pephub_response)
111110

112-
# if pephub_response.status_code != ResponseStatusCodes.OK_200:
113-
# raise ResponseError(message=json.loads(decoded_response).get("detail"))
114-
# else:
115-
return decoded_response
111+
if pephub_response.status_code != ResponseStatusCodes.OK_200:
112+
raise ResponseError(message=json.loads(decoded_response).get("detail"))
113+
else:
114+
return decoded_response
116115

117116
def _request_jwt_from_pephub(self, client_data: ClientData) -> str:
118117
pephub_response = self.send_request(

‎rafalstepien_public_project.csv

-3
This file was deleted.

‎requirements/requirements-all.txt

Whitespace-only changes.

‎requirements/requirements-dev.txt

Whitespace-only changes.

‎setup.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import sys
2+
import os
3+
from setuptools import find_packages, setup
4+
from pephubclient import __app_name__, __version__, __author__
5+
6+
PACKAGE = __app_name__
7+
REQDIR = "requirements"
8+
9+
# Additional keyword arguments for setup().
10+
extra = {}
11+
12+
# Ordinary dependencies
13+
def read_reqs(reqs_name):
14+
deps = []
15+
with open(os.path.join(REQDIR, f"requirements-{reqs_name}.txt"), "r") as f:
16+
for l in f:
17+
if not l.strip():
18+
continue
19+
deps.append(l)
20+
return deps
21+
22+
23+
DEPENDENCIES = read_reqs("all")
24+
extra["install_requires"] = DEPENDENCIES
25+
26+
scripts = None
27+
28+
with open("README.md") as f:
29+
long_description = f.read()
30+
31+
setup(
32+
name=PACKAGE,
33+
packages=[PACKAGE],
34+
version=__version__,
35+
description="PEPhub command line interface.",
36+
long_description=long_description,
37+
long_description_content_type="text/markdown",
38+
classifiers=[
39+
"Development Status :: 1 - Planing",
40+
"License :: OSI Approved :: BSD License",
41+
"Programming Language :: Python :: 3.8",
42+
"Programming Language :: Python :: 3.9",
43+
"Programming Language :: Python :: 3.10",
44+
"Topic :: Scientific/Engineering :: Bio-Informatics",
45+
],
46+
keywords="project, bioinformatics, metadata",
47+
url=f"https://github.com/databio/{PACKAGE}/",
48+
author=__author__,
49+
license="BSD2",
50+
entry_points={
51+
"console_scripts": [
52+
"pephubclient = pephubclient.__main__:main",
53+
],
54+
},
55+
package_data={PACKAGE: ["templates/*"]},
56+
scripts=scripts,
57+
include_package_data=True,
58+
test_suite="tests",
59+
tests_require=read_reqs("dev"),
60+
setup_requires=(
61+
["pytest-runner"] if {"test", "pytest", "ptr"} & set(sys.argv) else []
62+
),
63+
**extra,
64+
)

‎static/pephubclient_login.png

-84.6 KB
Binary file not shown.

‎static/pephubclient_pull.png

-86 KB
Binary file not shown.

‎tests/test_pephubclient.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from unittest.mock import Mock, patch, mock_open
33
from pephubclient.pephubclient import PEPHubClient
4-
from error_handling.exceptions import ResponseError
4+
from pephubclient.exceptions import ResponseError
55

66

77
def test_login(mocker, test_jwt_response, test_client_data, test_access_token):

0 commit comments

Comments
 (0)
Please sign in to comment.