Skip to content

Commit 8d0ad6a

Browse files
authored
♻️ Maintenance: repo-wide cleanup of modules setups and utils (ITISFoundation#2669)
- recycle aiohttp utils - proposal: Naming convention fake and mock - proposal: setup.py - use VERSION as the source of truth for each module in the repo - informative linter check for python 3.10
1 parent 909a46a commit 8d0ad6a

File tree

65 files changed

+681
-1620
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+681
-1620
lines changed

.github/README.md renamed to .github/tips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tips on .github configuration
22

3-
3+
WARNING: do not name this file as README.md since it will be rendered in the main project page of github instead of the README.md of the base directory.
44

55
## [Issues and pull request templates](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates)
66

.github/workflows/ci-testing-deploy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ jobs:
596596
runs-on: ${{ matrix.os }}
597597
strategy:
598598
matrix:
599-
python: [3.8, 3.9]
599+
python: [3.8, 3.9, "3.10"]
600600
os: [ubuntu-20.04]
601601
docker_buildx: [v0.5.1]
602602
docker_compose: [1.29.1]
@@ -2390,7 +2390,6 @@ jobs:
23902390
unit-test-dask-task-models-library,
23912391
unit-test-dask-sidecar,
23922392
unit-test-frontend,
2393-
unit-test-python-linting,
23942393
unit-test-service-integration,
23952394
unit-test-service-library,
23962395
unit-test-settings-library,
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
[bumpversion]
22
current_version = 0.1.0
33
commit = True
4-
tag = True
4+
message = packages/dask-task-models-library version: {current_version} → {new_version}
5+
tag = False
56

6-
[bumpversion:file:setup.py]
7-
search = version='{current_version}'
8-
replace = version='{new_version}'
9-
10-
[bumpversion:file:src/dask_task_models_library/__init__.py]
11-
search = __version__ = '{current_version}'
12-
replace = __version__ = '{new_version}'
7+
[bumpversion:file:VERSION]
138

149
[bdist_wheel]
1510
universal = 1
1611

1712
[aliases]
18-
# Define setup.py command aliases here
1913
test = pytest
Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
11
import re
22
import sys
33
from pathlib import Path
4+
from typing import Set
45

56
from setuptools import find_packages, setup
67

7-
here = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
88

9+
def read_reqs(reqs_path: Path) -> Set[str]:
10+
return {
11+
r
12+
for r in re.findall(
13+
r"(^[^#\n-][\w\[,\]]+[-~>=<.\w]*)",
14+
reqs_path.read_text(),
15+
re.MULTILINE,
16+
)
17+
if isinstance(r, str)
18+
}
919

10-
def read_reqs(reqs_path: Path):
11-
return re.findall(
12-
r"(^[^#\n-][\w\[,\]]+[-~>=<.\w]*)", reqs_path.read_text(), re.MULTILINE
13-
)
1420

21+
CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
1522

16-
install_requirements = read_reqs(
17-
here / "requirements" / "_base.in"
23+
24+
INSTALL_REQUIREMENTS = tuple(
25+
read_reqs(CURRENT_DIR / "requirements" / "_base.in")
1826
) # WEAK requirements
1927

20-
test_requirements = read_reqs(here / "requirements" / "_test.txt") + [
21-
"simcore-models-library",
22-
] # STRONG requirements
28+
TEST_REQUIREMENTS = tuple(
29+
read_reqs(CURRENT_DIR / "requirements" / "_test.txt")
30+
| {
31+
"simcore-models-library",
32+
}
33+
) # STRICT requirements
2334

24-
readme = Path(here / "README.md").read_text()
2535

26-
setup(
36+
SETUP = dict(
2737
name="simcore-dask-task-models-library",
28-
version="0.1.0",
38+
version=Path(CURRENT_DIR / "VERSION").read_text().strip(),
2939
author="Sylvain Anderegg (sanderegg)",
3040
description="Core service library for simcore pydantic dask task models",
3141
python_requires="~=3.8",
@@ -36,14 +46,18 @@ def read_reqs(reqs_path: Path):
3646
"Natural Language :: English",
3747
"Programming Language :: Python :: 3.8",
3848
],
39-
long_description=readme,
49+
long_description=Path(CURRENT_DIR / "README.md").read_text(),
4050
license="MIT license",
41-
install_requires=install_requirements,
51+
install_requires=INSTALL_REQUIREMENTS,
4252
packages=find_packages(where="src"),
4353
package_dir={"": "src"},
4454
include_package_data=True,
4555
test_suite="tests",
46-
tests_require=test_requirements,
47-
extras_require={"test": test_requirements},
56+
tests_require=TEST_REQUIREMENTS,
57+
extras_require={"test": TEST_REQUIREMENTS},
4858
zip_safe=False,
4959
)
60+
61+
62+
if __name__ == "__main__":
63+
setup(**SETUP)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import pkg_resources
2+
3+
__version__: str = pkg_resources.get_distribution(
4+
"simcore-dask-task-models-library"
5+
).version

packages/models-library/setup.cfg

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
[bumpversion]
22
current_version = 0.1.0
33
commit = True
4-
tag = True
4+
message = packages/models-library version: {current_version} → {new_version}
5+
tag = False
56

6-
[bumpversion:file:setup.py]
7-
search = version='{current_version}'
8-
replace = version='{new_version}'
9-
10-
[bumpversion:file:src/models_library/__init__.py]
11-
search = __version__ = '{current_version}'
12-
replace = __version__ = '{new_version}'
7+
[bumpversion:file:VERSION]
138

149
[bdist_wheel]
1510
universal = 1

packages/models-library/setup.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
import re
22
import sys
33
from pathlib import Path
4+
from typing import Set
45

56
from setuptools import find_packages, setup
67

7-
here = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
88

9+
def read_reqs(reqs_path: Path) -> Set[str]:
10+
return {
11+
r
12+
for r in re.findall(
13+
r"(^[^#\n-][\w\[,\]]+[-~>=<.\w]*)",
14+
reqs_path.read_text(),
15+
re.MULTILINE,
16+
)
17+
if isinstance(r, str)
18+
}
919

10-
def read_reqs(reqs_path: Path):
11-
return re.findall(
12-
r"(^[^#\n-][\w\[,\]]+[-~>=<.\w]*)", reqs_path.read_text(), re.MULTILINE
13-
)
1420

21+
CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
1522

16-
install_requirements = read_reqs(
17-
here / "requirements" / "_base.in"
23+
24+
INSTALL_REQUIREMENTS = tuple(
25+
read_reqs(CURRENT_DIR / "requirements" / "_base.in")
1826
) # WEAK requirements
1927

20-
test_requirements = read_reqs(
21-
here / "requirements" / "_test.txt"
22-
) # STRONG requirements
28+
TEST_REQUIREMENTS = tuple(
29+
read_reqs(CURRENT_DIR / "requirements" / "_test.txt")
30+
) # STRICK requirements
2331

24-
readme = Path(here / "README.md").read_text()
2532

26-
setup(
33+
SETUP = dict(
2734
name="simcore-models-library",
28-
version="0.1.0",
35+
version=Path(CURRENT_DIR / "VERSION").read_text().strip(),
2936
author="Sylvain Anderegg (sanderegg)",
3037
description="Core service library for simcore pydantic models",
3138
python_requires="~=3.8",
@@ -36,14 +43,18 @@ def read_reqs(reqs_path: Path):
3643
"Natural Language :: English",
3744
"Programming Language :: Python :: 3.8",
3845
],
39-
long_description=readme,
46+
long_description=Path(CURRENT_DIR / "README.md").read_text(),
4047
license="MIT license",
41-
install_requires=install_requirements,
48+
install_requires=INSTALL_REQUIREMENTS,
4249
packages=find_packages(where="src"),
4350
package_dir={"": "src"},
4451
include_package_data=True,
4552
test_suite="tests",
46-
tests_require=test_requirements,
47-
extras_require={"test": test_requirements},
53+
tests_require=TEST_REQUIREMENTS,
54+
extras_require={"test": TEST_REQUIREMENTS},
4855
zip_safe=False,
4956
)
57+
58+
59+
if __name__ == "__main__":
60+
setup(**SETUP)

packages/models-library/src/models_library/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
# - "examples" = [ ...] keyword and NOT "example". See https://json-schema.org/understanding-json-schema/reference/generic.html#annotations
77
#
88

9+
import pkg_resources
910

10-
__version__ = "0.1.0"
11+
__version__: str = pkg_resources.get_distribution("simcore-models-library").version

packages/models-library/src/models_library/generics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ def __len__(self):
6464
class Envelope(GenericModel, Generic[DataT]):
6565
data: Optional[DataT]
6666
error: Optional[Any]
67+
# TODO: this needs to be more concreate e.g. { "error": { "reason": "Invalid" , "exception": "ValueError" } }

packages/postgres-database/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ Upgrades to given revision (get ``info`` to check history)
6262

6363
## Database Models
6464

65-
Entity Relationship Diagram (ERD) defined under ``simcore_postgres_database.models``:
66-
67-
![scripts/create_erd.py-output](doc/img/postgres-database-models.svg)
68-
6965
## Development
7066

7167
1. In order to create/modify/delete tables one can use sc-pg to start a clean database:

0 commit comments

Comments
 (0)