Skip to content

Commit

Permalink
cleaning old files
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Dec 11, 2023
1 parent 788a72a commit 419daf5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 131 deletions.
2 changes: 0 additions & 2 deletions pephub/exceptions.py

This file was deleted.

103 changes: 1 addition & 102 deletions pephub/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,115 +2,14 @@
from typing import List, Union, Tuple
from fastapi import Response, UploadFile
from fastapi.exceptions import HTTPException
from ubiquerg import VersionInHelpParser

from os.path import exists, basename
from yaml import safe_load
from os.path import basename
import zipfile
import io
import yaml

import peppy
from peppy.const import SAMPLE_DF_KEY
from pephub.exceptions import PepHubException

from ._version import __version__ as v
from .const import DEFAULT_PORT, PKG_NAME


def build_parser():
"""
Building argument parser
:return argparse.ArgumentParser
"""
banner = "%(prog)s - PEP web server"
additional_description = (
"For subcommand-specific options, type: '%(prog)s <subcommand> -h'"
)
additional_description += "\nhttps://github.com/pepkit/pepserver"

parser = VersionInHelpParser(
prog=PKG_NAME, description=banner, epilog=additional_description
)

parser.add_argument(
"-V", "--version", action="version", version="%(prog)s {v}".format(v=v)
)

msg_by_cmd = {"serve": "run the server"}

subparsers = parser.add_subparsers(dest="command")

def add_subparser(cmd, description):
return subparsers.add_parser(cmd, description=description, help=description)

sps = {}
# add arguments that are common for both subparsers
for cmd, desc in msg_by_cmd.items():
sps[cmd] = add_subparser(cmd, desc)
sps[cmd].add_argument(
"-c",
"--config",
required=False,
dest="config",
help="A path to the pepserver config file",
)

sps["serve"].add_argument(
"-p",
"--port",
dest="port",
type=int,
help="The port the webserver should be run on.",
default=DEFAULT_PORT,
)

sps["serve"].add_argument(
"-r",
"--reload",
dest="reload",
type=bool,
help="Run the server in reload configuration",
default=False,
)

sps["serve"].add_argument(
"--log-level",
dest="log_level",
type=str,
help="The level of logging to use",
default="INFO",
)

sps["serve"].add_argument(
"--uvicorn-log-level",
dest="uvicorn_log_level",
type=str,
help="The level of logging to use for uvicorn",
default="info",
)

return parser


def read_server_configuration(path: str) -> dict:
"""Read in a server configuration file at a specified path"""
if not exists(path):
raise FileNotFoundError(f"Configuration file at {path} could not be found.")
with open(path, "r") as f:
cfg = safe_load(f)
if cfg.get("data") is None:
raise PepHubException(
"'data' section is required in the configuration file."
)
if cfg["data"].get("path") is None:
raise PepHubException(
"No path to PEPs was specified in the configuration file."
)

return {
"data": {"path": cfg["data"]["path"], "index": cfg["data"].get("index")}
}


def get_project_sample_names(proj: peppy.Project) -> List[str]:
Expand Down
27 changes: 0 additions & 27 deletions pephub/route_examples.py

This file was deleted.

0 comments on commit 419daf5

Please sign in to comment.