Skip to content

Commit

Permalink
Develop core project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaguire committed Jul 18, 2024
1 parent 23f8ce2 commit 32f3051
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 48 deletions.
Empty file removed convAST/py.typed
Empty file.
1 change: 1 addition & 0 deletions convAST/__init__.py → convast/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
"""Module init"""
from .version import VERSION, VERSION_SHORT
38 changes: 38 additions & 0 deletions convast/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python
"""Defines CLI and main execution entrypoint to enable easier import
of key classes directly into other scripts"""

import argparse
from .utils import check_file_exists, initialise_logger

def generate_cli():
"""
Create the CLI interface for the AST entrypoint
"""
parser = argparse.ArgumentParser(
description="Converts antibiotic susceptibility "
"testing data to INSDC standardised format"
)

# takes input file and confirms it exists
parser.add_argument("input_file", help="The input file to convert", type=check_file_exists)
parser.add_argument(
"-f", "--format", help="Origin of input file", required=True, choices=["VITEK"]
)
parser.add_argument("-o", "--output", help="The output file destination")
return parser


def main():
"""
CLI entrypoint
"""
parser = generate_cli()
args = parser.parse_args()

if not args.output:
args.output = args.input_file.with_suffix(".insdc.csv")

logger = initialise_logger()

logger.info(f"Converting {args.input_file} as {args.format} to INSDC {args.output}")
3 changes: 3 additions & 0 deletions convast/convast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python

# implement parent convast class including linkml output
27 changes: 27 additions & 0 deletions convast/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""General utility functions for convast"""
from pathlib import Path
import logging
import argparse


def check_file_exists(file_path):
"""
Check if a given filepath exists
"""
file_path = Path(file_path)
if not file_path.exists():
raise argparse.ArgumentTypeError(f"{file_path} does not exist")
return file_path


def initialise_logger():
"""
Initialise the logger to stderr
"""
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s-%(levelname)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
logger = logging.getLogger(__name__)
return logger
5 changes: 3 additions & 2 deletions convAST/version.py → convast/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Version information for the package"""
_MAJOR = "0"
_MINOR = "1"
# On main and in a nightly release the patch should be one ahead of the last
Expand All @@ -7,5 +8,5 @@
# https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = ""

VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)
VERSION = "{0}.{1}.{2}{3}".format(_MAJOR, _MINOR, _PATCH, _SUFFIX)
VERSION_SHORT = f"{_MAJOR}.{_MINOR}"
VERSION = "{_MAJOR}.{_MINOR}.{_PATCH}{_SUFFIX}"
58 changes: 15 additions & 43 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,41 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
# See https://setuptools.pypa.io/en/latest/userguide/quickstart.html for more project configuration options.
name = "my-package"
name = "convast"
dynamic = ["version"]
readme = "README.md"
classifiers = [
"Intended Audience :: Science/Research",
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
authors = [
{name = "Allen Institute for Artificial Intelligence", email = "[email protected]"}
]
{name = "Finlay Maguire", email = "[email protected]"},
{name = "Amos Raphenya", email = "[email protected]"},]
requires-python = ">=3.8"
dependencies = [
# Add your own dependencies here
]
license = {file = "LICENSE"}

[project.scripts]
convast = "convast.cli:main"

[project.urls]
Homepage = "https://github.com/allenai/python-package-template"
Repository = "https://github.com/allenai/python-package-template"
Changelog = "https://github.com/allenai/python-package-template/blob/main/CHANGELOG.md"
Homepage = "https://github.com/pha4ge/convast"
Repository = "https://github.com/pha4ge/convast"
Changelog = "https://github.com/pha4ge/convast/blob/main/CHANGELOG.md"
# Documentation = "https://my-package.readthedocs.io/"

[project.optional-dependencies]
dev = [
"ruff",
"mypy>=1.0,<1.5",
"black>=23.0,<24.0",
"isort>=5.12,<5.13",
"pytest",
"pytest-sphinx",
"pytest-cov",
"twine>=1.11.0",
"build",
"setuptools",
"wheel",
"Sphinx>=4.3.0,<7.1.0",
"furo==2023.7.26",
"myst-parser>=1.0,<2.1",
"sphinx-copybutton==0.5.2",
"sphinx-autobuild==2021.3.14",
"sphinx-autodoc-typehints==1.23.3",
"packaging"
]

Expand All @@ -57,18 +47,13 @@ exclude = [
"*.tests.*",
"tests.*",
"tests",
"docs*",
"scripts*"
]

[tool.setuptools]
include-package-data = true

[tool.setuptools.package-data]
my_package = ["py.typed"]

[tool.setuptools.dynamic]
version = {attr = "my_package.version.VERSION"}
version = {attr = "convast.version.VERSION"}

[tool.black]
line-length = 100
Expand All @@ -86,35 +71,22 @@ exclude = '''
)
'''

[tool.isort]
profile = "black"
multi_line_output = 3

# You can override these pyright settings by adding a personal pyrightconfig.json file.
[tool.pyright]
reportPrivateImportUsage = false

[tool.ruff]
line-length = 115
target-version = "py39"

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]

[tool.mypy]
ignore_missing_imports = true
no_site_packages = true
check_untyped_defs = true

[[tool.mypy.overrides]]
module = "tests.*"
strict_optional = false
[tool.pylint.'MESSAGES CONTROL']
max-line-length = 115
disable = """
logging-fstring-interpolation
"""

[tool.pytest.ini_options]
testpaths = "tests/"
python_classes = [
"Test*",
"*Test"
]
log_format = "%(asctime)s - %(levelname)s - %(name)s - %(message)s"
log_level = "DEBUG"
3 changes: 0 additions & 3 deletions setup-requirements.txt

This file was deleted.

0 comments on commit 32f3051

Please sign in to comment.