Skip to content

Commit 6c4e055

Browse files
authored
♻️ repo cleanup and doc (#179)
1 parent 2b5ef28 commit 6c4e055

33 files changed

+318
-188
lines changed

.github/workflows/build-python-client.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,27 @@ jobs:
1818
uses: actions/setup-python@v2
1919
with:
2020
python-version: 3.10.14
21+
- name: install uv
22+
uses: yezz123/setup-uv@v4
2123
- name: Setup Python environment
2224
run: |
2325
git status
2426
make devenv
2527
source .venv/bin/activate
26-
- name: Process tag
28+
- name: Git tag to VERSION
2729
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
2830
run: |
2931
source .venv/bin/activate
3032
version=$(echo ${{ github.ref }} | grep -oP '(?<=refs/tags/v)\d+\.\d+\.\d+')
3133
python scripts/is_semantic_version.py "${version}"
32-
echo "${version}" > clients/python/client/VERSION
33-
- name: Generate client
34+
echo "${version}" > clients/python/VERSION
35+
- name: Auto-generate python_client and build distributions
3436
run: |
3537
source .venv/bin/activate
3638
cd clients/python
37-
make install-dev
38-
make dist-ci
39+
uv pip install -r requirements/dev.txt
40+
make python-client
41+
make dist
3942
- name: Set variables
4043
id: variables
4144
run: |
@@ -70,6 +73,8 @@ jobs:
7073
uses: actions/setup-python@v4
7174
with:
7275
python-version: ${{ matrix.python-version }}
76+
- name: install uv
77+
uses: yezz123/setup-uv@v4
7378
- name: Pip cache
7479
uses: actions/cache@v3
7580
with:
@@ -90,6 +95,7 @@ jobs:
9095
python -m pip install clients/python/artifacts/dist/${{needs.build.outputs.osparc}} --find-links=clients/python/artifacts/dist
9196
cd clients/python
9297
make install-unit-test
98+
uv pip list | grep osparc
9399
pytest -v --ignore=/artifacts/client --ignore=test/e2e
94100
95101
test-latest:
@@ -106,6 +112,8 @@ jobs:
106112
uses: actions/setup-python@v4
107113
with:
108114
python-version: ${{ matrix.python-version }}
115+
- name: install uv
116+
uses: yezz123/setup-uv@v4
109117
- name: Pip cache
110118
uses: actions/cache@v3
111119
with:
@@ -122,8 +130,8 @@ jobs:
122130
run: |
123131
python -m venv .venv
124132
source .venv/bin/activate
125-
python -m pip install pytest
126-
python -m pip install clients/python/artifacts/dist/${{needs.build.outputs.osparc}} --find-links=clients/python/artifacts/dist
133+
uv pip install pytest
134+
uv pip install clients/python/artifacts/dist/${{needs.build.outputs.osparc}} --find-links=clients/python/artifacts/dist
127135
cd clients/python
128136
make install-unit-test
129137
pytest -v --ignore=/artifacts/client --ignore=test/e2e

.gitignore

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@ tmp*
7878

7979
# auto generated python code
8080
/clients/python/artifacts/*
81-
/clients/python/client/build/*
82-
/clients/python/client/osparc/data/openapi.json
81+
/clients/python/src/build/*
82+
/clients/python/src/osparc/data/openapi.json
83+
/clients/python/VERSION
8384
/clients/python/test/e2e/pytest.ini
84-
/clients/python/client/VERSION
85+
86+
87+
# key-words in filename to ignore them
88+
*secret*
89+
*ignore*
90+
!.dockerignore
91+
!.gitignore

.pre-commit-config.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,13 @@ repos:
2727
types: ["file"]
2828
- repo: https://github.com/astral-sh/ruff-pre-commit
2929
# Ruff version.
30-
rev: v0.0.282
30+
rev: v0.6.2
3131
hooks:
3232
- id: ruff
33-
args: [ --fix, --exit-non-zero-on-fix ]
34-
- repo: https://github.com/pycqa/isort
35-
rev: 5.12.0
36-
hooks:
37-
- id: isort
38-
name: isort (python)
39-
args: ["--profile", "black"]
33+
args:
34+
- --fix
35+
- --exit-non-zero-on-fix
36+
- id: ruff-format
4037
- repo: https://github.com/psf/black
4138
rev: 23.7.0
4239
hooks:

.vscode/launch.template.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python Debugger: Current File",
9+
"type": "debugpy",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
},
14+
{
15+
"name": "Python: Run Test",
16+
"type": "debugpy",
17+
"request": "launch",
18+
"module": "pytest",
19+
"args": [
20+
"--ff",
21+
"--log-cli-level=INFO",
22+
"--pdb",
23+
"--setup-show",
24+
"-sx",
25+
"-vv",
26+
"--asyncio-mode=auto",
27+
"${file}"
28+
],
29+
"cwd": "${workspaceFolder}",
30+
"console": "integratedTerminal",
31+
"justMyCode": false
32+
}
33+
]
34+
}

.vscode/settings.template.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
{
2+
"files.associations": {
3+
".*rc": "ini",
4+
".env*": "ini",
5+
"**/requirements/*.in": "pip-requirements",
6+
"**/requirements/*.txt": "pip-requirements",
7+
"*logs.txt": "log",
8+
"*.logs*": "log",
9+
"*Makefile": "makefile",
10+
"docker-compose*.yml": "dockercompose",
11+
"Dockerfile*": "dockerfile"
12+
},
213
"pylint.args": [
314
"--rcfile=clients/python/.pylintrc"
415
]
File renamed without changes.

Makefile

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ include ./scripts/common.Makefile
22

33
PYTHON_DIR := $(CLIENTS_DIR)/python
44

5+
6+
.vscode/%.json: .vscode/%.template.json
7+
$(if $(wildcard $@), \
8+
@echo "WARNING ##### $< is newer than $@ ####"; diff -uN $@ $<; false;,\
9+
@echo "WARNING ##### $@ does not exist, cloning $< as $@ ############"; cp $< $@)
10+
11+
512
.PHONY: info
613
info: ## general information
714
# system
@@ -13,30 +20,32 @@ info: ## general information
1320
@which python
1421
@pip list
1522
# API
16-
@echo ' title : ' $(shell bash $(SCRIPTS_DIR)/jq.bash -r .info.title $(REPO_ROOT)/api/openapi.json)
17-
@echo ' version : ' $(shell bash $(SCRIPTS_DIR)/jq.bash -r .info.version $(REPO_ROOT)/api/openapi.json)
23+
@echo ' title : $(shell bash $(SCRIPTS_DIR)/jq.bash -r .info.title $(REPO_ROOT)/api/openapi.json)'
24+
@echo ' version : $(shell bash $(SCRIPTS_DIR)/jq.bash -r .info.version $(REPO_ROOT)/api/openapi.json)'
1825
# nox
1926
@echo nox --list-session
2027

2128

22-
.venv:
23-
@python3 --version
24-
python3 -m venv $@
29+
.venv: .check-uv-installed
30+
@uv venv $@
2531
## upgrading tools to latest version in $(shell python3 --version)
26-
$@/bin/pip3 --quiet install --upgrade \
27-
pip \
32+
@uv pip --quiet install --upgrade \
33+
pip~=24.0 \
2834
wheel \
29-
setuptools
30-
@$@/bin/pip3 list --verbose
35+
setuptools \
36+
uv
37+
@uv pip list
38+
3139

3240
.PHONY: devenv
33-
devenv: .venv ## create a python virtual environment with dev tools (e.g. linters, etc)
34-
$</bin/pip3 --quiet install -r requirements.txt
41+
devenv: .venv .vscode/settings.json .vscode/launch.json ## create a python virtual environment with dev tools (e.g. linters, etc)
42+
@uv pip --quiet install -r requirements.txt
3543
# Installing pre-commit hooks in current .git repo
3644
@$</bin/pre-commit install
3745
@echo "To activate the venv, execute 'source .venv/bin/activate'"
3846

3947

48+
4049
## VERSION -------------------------------------------------------------------------------
4150

4251
.PHONY: version-patch version-minor version-major
@@ -53,6 +62,7 @@ define _bumpversion
5362
endef
5463

5564
## DOCUMENTATION ------------------------------------------------------------------------
65+
5666
.PHONY: http-doc docs
5767
docs: ## generate docs
5868
# generate documentation
@@ -69,21 +79,3 @@ http-doc: docs ## generates and serves doc
6979
# starting doc website
7080
@echo "Check site on http://127.0.0.1:50001/"
7181
python3 -m http.server 50001 --bind 127.0.0.1
72-
73-
## CLEAN -------------------------------------------------------------------------------
74-
75-
.PHONY: clean-hooks
76-
clean-hooks: ## Uninstalls git pre-commit hooks
77-
@-pre-commit uninstall 2> /dev/null || rm .git/hooks/pre-commit
78-
79-
_git_clean_args := -dx --force --exclude=.vscode --exclude=TODO.md --exclude=.venv --exclude=.python-version --exclude="*keep*"
80-
81-
.check-clean:
82-
@git clean -n $(_git_clean_args)
83-
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
84-
@echo -n "$(shell whoami), are you REALLY sure? [y/N] " && read ans && [ $${ans:-N} = y ]
85-
86-
87-
clean: .check-clean ## cleans all unversioned files in project and temp files create by this makefile
88-
# Cleaning unversioned
89-
@git clean $(_git_clean_args)

0 commit comments

Comments
 (0)