From 144fc84d7ac4a0d5ce4446cb508503a2b895bb0c Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Thu, 24 Aug 2023 15:14:41 +0530 Subject: [PATCH 01/11] WIP pyproject.toml --- pyproject.toml | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..7b6bd2540 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,62 @@ +[tool.poetry] +name = "ersilia" +version = "0.1.22" +description = "A hub of AI/ML models for open source drug discovery and global health" +license = "GPLv3" +authors = ["Ersilia Open Source Initiative "] +readme = "README.md" +homepage = "https://ersilia.io" +repository = "https://github.com/ersilia-os/ersilia" +documentation = "https://ersilia.io/model-hub" +keywords= ["drug-discovery", "machine-learning", "ersilia", "open-science", "global-health", "model-hub", "infectious-diseases"] +classifiers=[ + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering :: Artificial Intelligence", +] +packages = [ + {include = "ersilia"}, +] +include = [ + "ersilia/hub/content/metadata/*.txt", + "ersilia/io/types/examples/*.tsv, +] + + +[tool.poetry.dependencies] +python = ">=3.7" +inputimeout = "^1.0.4" +emoji = "^2.8.0" +validators = [ + {version="0.20.0", python="3.7.*"}, + {version="~0.21.0", python=">=3.8"}, +] +h5py = [ + {version="~3.7.0", python=">=3.7", markers="extra=='lake'"}, + {version="~3.9.0", python=">=3.7"} +] +loguru = [ + {version="^0.6.0", python=">=3.7", markers="extra=='lake'"}, + {version="~0.7.0", python=">=3.7"} +] +pyairtable = "<2" +PyYAML = "^6.0.1" +dockerfile-parse = "^2.0.1" +tqdm = "^4.66.1" +click = "^8.1.7" +docker = "^6.1.3" + + +[tool.poetry.extras] +# Instead of using poetry dependency groups, we use extras to make it pip installable +lake = ["isaura"] +docs = ["sphinx", "jinja2"] +test = ["pytest", "fuzzywuzzy"] + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" From d6eec0cf9e50e00a8705537f75709b2c654a1756 Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Mon, 28 Aug 2023 14:42:30 +0530 Subject: [PATCH 02/11] Add includes and update dependencie specs --- pyproject.toml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7b6bd2540..c8f6e592b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,12 +21,11 @@ classifiers=[ packages = [ {include = "ersilia"}, ] -include = [ +includ = [ "ersilia/hub/content/metadata/*.txt", - "ersilia/io/types/examples/*.tsv, + "ersilia/io/types/examples/*.tsv", ] - [tool.poetry.dependencies] python = ">=3.7" inputimeout = "^1.0.4" @@ -35,20 +34,19 @@ validators = [ {version="0.20.0", python="3.7.*"}, {version="~0.21.0", python=">=3.8"}, ] -h5py = [ - {version="~3.7.0", python=">=3.7", markers="extra=='lake'"}, - {version="~3.9.0", python=">=3.7"} -] -loguru = [ - {version="^0.6.0", python=">=3.7", markers="extra=='lake'"}, - {version="~0.7.0", python=">=3.7"} -] +h5py = "^3.7.0" # For compatibility with isaura +loguru = "^0.6.0" # For compatibility with isaura pyairtable = "<2" PyYAML = "^6.0.1" dockerfile-parse = "^2.0.1" tqdm = "^4.66.1" click = "^8.1.7" docker = "^6.1.3" +isaura = {version="0.1", optional=true} +pytest = {version = "^7.4.0", optional = true} +fuzzywuzzy = {version = "^0.18.0", optional = true} +sphinx = {version = ">=5.3.0", optional = true} # For compatibility with python 3.7.x +jinja2 = {version = "^3.1.2", optional = true} [tool.poetry.extras] @@ -56,6 +54,8 @@ docker = "^6.1.3" lake = ["isaura"] docs = ["sphinx", "jinja2"] test = ["pytest", "fuzzywuzzy"] +#all = [lake, docs, test] + [build-system] requires = ["poetry-core"] From e858abe9f15a786f51ce2877ec75f9183ccd19b8 Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Mon, 28 Aug 2023 15:09:53 +0530 Subject: [PATCH 03/11] Make static verion writer update version in pyproject.toml --- .github/scripts/static_version_writer.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/scripts/static_version_writer.py b/.github/scripts/static_version_writer.py index 1a7fadd49..94c943dec 100644 --- a/.github/scripts/static_version_writer.py +++ b/.github/scripts/static_version_writer.py @@ -1,10 +1,22 @@ import os -import os +import re from importlib.util import module_from_spec, spec_from_file_location ROOT = os.path.dirname(os.path.abspath(__file__)) +def version_writer(func): + def wrapper(package_path): + version = func(package_path) + toml_path = os.path.join(package_path, "..", "pyproject.toml") + with open(toml_path, "r") as f: + toml_content = f.read() + toml_content = re.sub("version\s=\s\"[0-9\.]+\"", f"version = \"{version}\"", toml_content) + with open(toml_path, "w") as f: + f.write(toml_content) + return version + return wrapper +@version_writer def get_version(package_path): spec = spec_from_file_location("version", os.path.join(package_path, "_version.py")) module = module_from_spec(spec) @@ -13,9 +25,10 @@ def get_version(package_path): return version + try: version = get_version(os.path.join(ROOT, "..", "..", "ersilia")) except: version = get_version(os.path.join(ROOT, "ersilia")) -print(version) +print(version) \ No newline at end of file From 2ae3fa001f416f63234946ebacc09f43dfba8595 Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Mon, 28 Aug 2023 15:10:13 +0530 Subject: [PATCH 04/11] fix typo --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c8f6e592b..bdd8a553e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ersilia" -version = "0.1.22" +version = "0.1.24" description = "A hub of AI/ML models for open source drug discovery and global health" license = "GPLv3" authors = ["Ersilia Open Source Initiative "] @@ -21,7 +21,7 @@ classifiers=[ packages = [ {include = "ersilia"}, ] -includ = [ +include = [ "ersilia/hub/content/metadata/*.txt", "ersilia/io/types/examples/*.tsv", ] From 31f6a60bfffa25c92eb12f32a3b7b39894ffca3f Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Mon, 28 Aug 2023 15:10:59 +0530 Subject: [PATCH 05/11] build with poetry --- .github/workflows/python-publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 2fc056217..2ab152006 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -39,5 +39,6 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel + # python setup.py sdist bdist_wheel + poetry build twine upload --verbose --skip-existing dist/* -u $TWINE_USERNAME -p $TWINE_PASSWORD From e6816f6a877033f8b5dc2ba758f6a5f27a265741 Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Wed, 30 Aug 2023 20:02:11 +0530 Subject: [PATCH 06/11] Add entrypoint --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index bdd8a553e..bea91ae69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,8 @@ docs = ["sphinx", "jinja2"] test = ["pytest", "fuzzywuzzy"] #all = [lake, docs, test] +[tool.poetry.scripts] +ersilia = "ersilia.cli:cli" [build-system] requires = ["poetry-core"] From 54daafec82cc4b6aabc106829e20c84d63bcd97a Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Wed, 30 Aug 2023 20:18:32 +0530 Subject: [PATCH 07/11] add bentoml install as entrypoint script --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index bea91ae69..174abad0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ test = ["pytest", "fuzzywuzzy"] [tool.poetry.scripts] ersilia = "ersilia.cli:cli" +bentoml_requirement = "ersilia.setup.requirements.bentoml:install" [build-system] requires = ["poetry-core"] From 8d719f751864a2c4460de7a9690e140889db0300 Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Thu, 31 Aug 2023 13:19:20 +0530 Subject: [PATCH 08/11] update bentoml entrypoint --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 174abad0a..1c845abaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ test = ["pytest", "fuzzywuzzy"] [tool.poetry.scripts] ersilia = "ersilia.cli:cli" -bentoml_requirement = "ersilia.setup.requirements.bentoml:install" +bentoml = "ersilia.setup.requirements.bentoml:install" [build-system] requires = ["poetry-core"] From 3573d50e48df7707f41b9284f53ca79ef7d1f947 Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Thu, 31 Aug 2023 15:26:57 +0530 Subject: [PATCH 09/11] modify bentoml entrypoint --- ersilia/setup/requirements/__init__.py | 8 ++++++++ pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ersilia/setup/requirements/__init__.py b/ersilia/setup/requirements/__init__.py index e69de29bb..deec4e01b 100644 --- a/ersilia/setup/requirements/__init__.py +++ b/ersilia/setup/requirements/__init__.py @@ -0,0 +1,8 @@ +from .bentoml import BentoMLRequirement + +def check_bentoml(): + req = BentoMLRequirement() + if not req.is_bentoml_ersilia_version(): + req.install() + return + diff --git a/pyproject.toml b/pyproject.toml index 1c845abaf..91526df19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ test = ["pytest", "fuzzywuzzy"] [tool.poetry.scripts] ersilia = "ersilia.cli:cli" -bentoml = "ersilia.setup.requirements.bentoml:install" +bentoml = "ersilia.setup.requirements:check_bentoml" [build-system] requires = ["poetry-core"] From bcd4a617cb49d9b6961b11a632cb60db4525d2db Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Thu, 31 Aug 2023 15:44:31 +0530 Subject: [PATCH 10/11] add levenshtein as requirement for fuzzywuzzy --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 91526df19..37dabae4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,13 +47,14 @@ pytest = {version = "^7.4.0", optional = true} fuzzywuzzy = {version = "^0.18.0", optional = true} sphinx = {version = ">=5.3.0", optional = true} # For compatibility with python 3.7.x jinja2 = {version = "^3.1.2", optional = true} +levenshtein = {version = "^0.21.1", optional = true} # For faster fuzzy search [tool.poetry.extras] # Instead of using poetry dependency groups, we use extras to make it pip installable lake = ["isaura"] docs = ["sphinx", "jinja2"] -test = ["pytest", "fuzzywuzzy"] +test = ["pytest", "fuzzywuzzy", "levenshtein"] #all = [lake, docs, test] [tool.poetry.scripts] From 3bba07722fc43eefc5b50477882816929bae7624 Mon Sep 17 00:00:00 2001 From: dhanshreea Date: Thu, 31 Aug 2023 15:59:00 +0530 Subject: [PATCH 11/11] update version in pyproject.toml; update publish workflow to use poetry --- .github/workflows/python-publish.yml | 12 ++++++++---- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 2ab152006..bf9cf0389 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -28,10 +28,14 @@ jobs: wget https://raw.githubusercontent.com/ersilia-os/ersilia/master/ersilia/_static_version.py mv _static_version.py ersilia/. - - name: Install dependencies + - name: Install Poetry run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine + python -m pip install --upgrade pip + pip install setuptools wheel twine + curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - + source $HOME/.poetry/env + echo `poetry --version` + echo "Poetry successfully installed" - name: Build and publish env: @@ -39,6 +43,6 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - # python setup.py sdist bdist_wheel + source $HOME/.poetry/env poetry build twine upload --verbose --skip-existing dist/* -u $TWINE_USERNAME -p $TWINE_PASSWORD diff --git a/pyproject.toml b/pyproject.toml index 37dabae4b..1b8857f65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ersilia" -version = "0.1.24" +version = "0.1.27" description = "A hub of AI/ML models for open source drug discovery and global health" license = "GPLv3" authors = ["Ersilia Open Source Initiative "]