From 042e18af9662644d34a2026c051903652401bbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0lker=20SI=C4=9EIRCI?= Date: Tue, 6 Aug 2024 14:20:11 +0300 Subject: [PATCH] Initial Commit --- .devcontainer/devcontainer.json | 2 +- .pre-commit-config.yaml | 2 +- Makefile | 10 +- README.md | 10 +- docker-compose.yml | 8 +- docs/index.md | 2 +- docs/reference.md | 4 +- mkdocs.yml | 8 +- pyproject.toml | 23 ++-- .../__init__.py | 2 +- src/bert_score_api/main.py | 0 src/python_template/placeholder.py | 105 ------------------ src/python_template/scripts/__init__.py | 1 - src/python_template/scripts/placeholder.py | 9 -- tests/.gitkeep | 0 tests/test_placeholder.py | 26 ----- 16 files changed, 36 insertions(+), 176 deletions(-) rename src/{python_template => bert_score_api}/__init__.py (77%) create mode 100644 src/bert_score_api/main.py delete mode 100644 src/python_template/placeholder.py delete mode 100644 src/python_template/scripts/__init__.py delete mode 100644 src/python_template/scripts/placeholder.py create mode 100644 tests/.gitkeep delete mode 100644 tests/test_placeholder.py diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c8d6c15..2a7f9fd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "name": "python_template", + "name": "bert_score_api", "dockerComposeFile": [ "../docker-compose.yml", "docker-compose.yml" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26c3a64..1a3ebcd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,7 +48,7 @@ repos: # rev: v0.991 # hooks: # - id: mypy - # files: python_template + # files: bert_score_api # additional_dependencies: [types-PyYAML, rich] # args: [ # "--strict", diff --git a/Makefile b/Makefile index 7abf9c3..8b7026b 100644 --- a/Makefile +++ b/Makefile @@ -2,17 +2,17 @@ # chain commands together with semicolon .ONESHELL: SHELL=/bin/bash -ROOT_DIR=python-template -PACKAGE=src/python_template +ROOT_DIR=bert-score-api +PACKAGE=src/bert_score_api PYTHON = python PYTHON_VERSION=3.11 DOC_DIR=./docs TEST_DIR=./tests TEST_MARKER=placeholder TEST_OUTPUT_DIR=tests_outputs -PRECOMMIT_FILE_PATHS=./python_template/__init__.py -PROFILE_FILE_PATH=./python_template/__init__.py -DOCKER_IMAGE=python-template +PRECOMMIT_FILE_PATHS=./bert_score_api/__init__.py +PROFILE_FILE_PATH=./bert_score_api/__init__.py +DOCKER_IMAGE=bert-score-api DOCKER_TARGET=development # TODO: add source for rye diff --git a/README.md b/README.md index f66b1c8..a643506 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Python Template +# BERT Score API ## Project Structure @@ -33,19 +33,19 @@ make -s install ```bash # Development build (800 MB) -docker build --tag python-template --file docker/Dockerfile --target development . +docker build --tag bert-score-api --file docker/Dockerfile --target development . # Production build (145 MB) -docker build --tag python-template --file docker/Dockerfile --target production . +docker build --tag bert-score-api --file docker/Dockerfile --target production . ``` - To run command inside the container: ```bash -docker run -it python-template:latest bash +docker run -it bert-score-api:latest bash # Temporary container -docker run --rm -it python-template:latest bash +docker run --rm -it bert-score-api:latest bash ``` ## IDE Setings diff --git a/docker-compose.yml b/docker-compose.yml index bb2660d..b1bae97 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,16 @@ version: "3.9" services: - python-template-dev: - image: python-template-dev:latest + bert-score-api-dev: + image: bert-score-api-dev:latest build: context: . dockerfile: docker/Dockerfile target: development # ports: # - 8080:8080 - python-template-prod: - image: python-template-prod:latest + bert-score-api-prod: + image: bert-score-api-prod:latest build: context: . dockerfile: docker/Dockerfile diff --git a/docs/index.md b/docs/index.md index 5b990f1..384eb08 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,5 @@ This site contains the project documentation for the -`python_template` project. +`bert_score_api` project. ## Table Of Contents diff --git a/docs/reference.md b/docs/reference.md index 4eec471..f7bc20b 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -1,6 +1,6 @@ This part of the project documentation focuses on an **information-oriented** approach. Use it as a reference for the technical implementation of the -`python_template` project code. +`bert_score_api` project code. -::: python_template +::: bert_score_api diff --git a/mkdocs.yml b/mkdocs.yml index 27290d1..a4428b4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,8 +1,8 @@ -site_name: Python Template +site_name: Bert Score Api site_dir: public -site_url: https://github.com/ilkersigirci/python-template -# repo_url: https://gitlab.com/ilkersigirci/python-template # # For GitLab -repo_url: https://ilkersigirci.github.io/python-template/ # For GitHub +site_url: https://github.com/ilkersigirci/bert-score-api +# repo_url: https://gitlab.com/ilkersigirci/bert-score-api # # For GitLab +repo_url: https://ilkersigirci.github.io/bert-score-api/ # For GitHub # repo_name: GitLab repo_name: GitHub diff --git a/pyproject.toml b/pyproject.toml index 0fa84b7..866a5d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,21 +1,22 @@ [project] -name = "python_template" +name = "bert_score_api" version = "0.0.0" -description = "Python Template" +description = "Bert Score API" # NOTE: Overwrites .python-version # requires-python = ">=3.11,<3.13" authors = [ - {name = "template", email = "template@github.com"}, + {name = "Ilker SIGIRCI", email = "sigirci.ilker@gmail.com"}, ] maintainers = [ - {name = "template", email = "template@github.com"}, + {name = "Ilker SIGIRCI", email = "sigirci.ilker@gmail.com"}, ] readme = "README.md" keywords = [ - "template" + "bert", + "fastapi", ] classifiers = [ @@ -63,7 +64,7 @@ name = "default" url = "https://pypi.org/simple/" [tool.rye.scripts] -placeholder = "python_template.scripts.placeholder:placeholder_script" +placeholder = "bert_score_api.scripts.placeholder:placeholder_script" [tool.pytest.ini_options] minversion = "7.0.0" @@ -75,7 +76,7 @@ addopts = [ # "--strict-markers", # "--doctest-modules", # NOTE: cov is not working with pycharm debugger. Enable it later! -# "--cov python_template", +# "--cov bert_score_api", # "--cov-report=xml", # "--cov-report html", ] @@ -107,7 +108,7 @@ extend-exclude = [ [tool.ruff.lint.per-file-ignores] "__init__.py" = ["E402", "F401"] # "path/to/file.py" = ["E402"] -# 'python_template/__init__.py' = ['F405', 'F403'] +# 'bert_score_api/__init__.py' = ['F405', 'F403'] # [tool.ruff.flake8-quotes] # inline-quotes = "single" @@ -171,7 +172,7 @@ combine-as-imports = true # Read more here: https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file [tool.mypy] # python_version = "3.8" -files = ["src/python_template"] +files = ["src/bert_score_api"] # exclude = ['^tests/'] strict = true show_error_codes = true @@ -184,7 +185,7 @@ ignore_missing_imports = true check_untyped_defs = true [tool.coverage.run] -source = ['src/python_template'] +source = ['src/bert_score_api'] branch = true context = '${CONTEXT}' @@ -200,7 +201,7 @@ exclude_lines = [ # [tool.coverage.paths] # source = [ -# 'src/python_template/', +# 'src/bert_score_api/', # ] [tool.hatch.metadata] diff --git a/src/python_template/__init__.py b/src/bert_score_api/__init__.py similarity index 77% rename from src/python_template/__init__.py rename to src/bert_score_api/__init__.py index 28253b4..4140a1a 100644 --- a/src/python_template/__init__.py +++ b/src/bert_score_api/__init__.py @@ -3,4 +3,4 @@ from importlib.metadata import version # Fetches the version of the package as defined in pyproject.toml -__version__ = version("python_template") +__version__ = version("bert_score_api") diff --git a/src/bert_score_api/main.py b/src/bert_score_api/main.py new file mode 100644 index 0000000..e69de29 diff --git a/src/python_template/placeholder.py b/src/python_template/placeholder.py deleted file mode 100644 index 58f70b1..0000000 --- a/src/python_template/placeholder.py +++ /dev/null @@ -1,105 +0,0 @@ -"""Placeholder file to provide several sample math calculations. - -This module allows the user to make mathematical calculations. -Adapted from: https://realpython.com/python-project-documentation-with-mkdocs/ - - -Examples: - >>> from python_template import placeholder - >>> placeholder.add(2, 4) - 6.0 - >>> placeholder.multiply(2.0, 4.0) - 8.0 - >>> from python_template.placeholder import divide - >>> divide(4.0, 2) - 2.0 - -The module contains the following functions: - -- `add(a, b)` - Returns the sum of two numbers. -- `subtract(a, b)` - Returns the difference of two numbers. -- `multiply(a, b)` - Returns the product of two numbers. -- `divide(a, b)` - Returns the quotient of two numbers. -""" - - -def add(a: float | int, b: float | int) -> float: - """Compute and return the sum of two numbers. - - Examples: - >>> add(4.0, 2.0) - 6.0 - >>> add(4, 2) - 6.0 - - Args: - a: A number representing the first addend in the addition. - b: A number representing the second addend in the addition. - - Returns: - A number representing the arithmetic sum result of `a` and `b`. - """ - return float(a + b) - - -def subtract(a: float | int, b: float | int) -> float: - """Compute and return the substaction of two numbers. - - Examples: - >>> subtract(4.0, 2.0) - 2.0 - >>> subtract(4, 2) - 2.0 - - Args: - a: A number representing the first substracter in the substract. - b: A number representing the second substracter in the substract. - - Returns: - A number representing the substract result of `a` and `b`. - """ - return float(a - b) - - -def multiply(a: float | int, b: float | int) -> float: - """Compute and return the multiplication of two numbers. - - Examples: - >>> multiply(4.0, 2.0) - 8.0 - >>> multiply(4, 2) - 8.0 - - Args: - a: A number representing the first multiplicator in the multiply. - b: A number representing the second multiplicator in the multiply. - - Returns: - A number representing the multiplied result of `a` and `b`. - """ - return float(a * b) - - -def divide(a: float | int, b: float | int) -> float: - """Compute and return the division of two numbers. - - Examples: - >>> divide(4.0, 2.0) - 2.0 - >>> divide(4, 2) - 2.0 - - Args: - a: A number representing the first divider in the divide. - b: A number representing the second divider in the divide. - - Returns: - A number representing the division result of `a` and `b`. - - Raises: - ZeroDivisionError: If `b` is zero. - """ - if b == 0: - raise ZeroDivisionError("division by zero") - - return float(a / b) diff --git a/src/python_template/scripts/__init__.py b/src/python_template/scripts/__init__.py deleted file mode 100644 index 1d097ad..0000000 --- a/src/python_template/scripts/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Useful python cli scripts.""" diff --git a/src/python_template/scripts/placeholder.py b/src/python_template/scripts/placeholder.py deleted file mode 100644 index b4a5fe9..0000000 --- a/src/python_template/scripts/placeholder.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Useful python cli scripts.""" - - -def placeholder_script(): - """Script that can be run in the command line. - - More detail: https://setuptools.pypa.io/en/latest/userguide/entry_point.html - """ - print("This is a placeholder script that can be run as `entry point`") # noqa: T201 diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_placeholder.py b/tests/test_placeholder.py deleted file mode 100644 index d89dc7f..0000000 --- a/tests/test_placeholder.py +++ /dev/null @@ -1,26 +0,0 @@ -import pytest - -from python_template.placeholder import add, divide, multiply, subtract - - -def test_add(): - assert add(2, 4) == 6.0 - assert add(2.0, 4.0) == 6.0 - - -def test_subtract(): - assert subtract(4.0, 2.0) == 2.0 - assert subtract(4, 2) == 2.0 - - -def test_multiply(): - assert multiply(2.0, 4.0) == 8.0 - assert multiply(2, 4) == 8.0 - - -def test_divide(): - assert divide(4.0, 2) == 2.0 - assert divide(4, 2) == 2.0 - - with pytest.raises(ZeroDivisionError): - divide(4, 0)