Skip to content

♻️ repo cleanup and doc #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b73420b
minor sorting
pcrespov Aug 27, 2024
21bfabc
renamed _model as _settings
pcrespov Aug 27, 2024
77ecad3
minor
pcrespov Aug 27, 2024
868d310
ignores
pcrespov Aug 27, 2024
d528996
names
pcrespov Aug 27, 2024
bc8e96c
doc
pcrespov Aug 27, 2024
ec7d439
make clean and vscode templates
pcrespov Aug 27, 2024
ffc1eaf
minor
pcrespov Aug 27, 2024
1ec3731
cleanup
pcrespov Aug 27, 2024
1cae133
doc
pcrespov Aug 27, 2024
9aed258
sorts imports
pcrespov Aug 27, 2024
387bec4
updates pre-commit config
pcrespov Aug 27, 2024
2a96648
updates pre-commit config
pcrespov Aug 27, 2024
d5b7678
updates sort
pcrespov Aug 27, 2024
e0ad4ba
upgrading to pyproject.toml
pcrespov Aug 27, 2024
8c74a1a
moved
pcrespov Aug 27, 2024
1148f7a
new location for VERSION file and adapted scripts to the new folder s…
pcrespov Aug 28, 2024
4ce601d
cleanup Makefile
pcrespov Aug 28, 2024
452dadc
fixes build
pcrespov Aug 28, 2024
7a6e73c
fixes setup
pcrespov Aug 28, 2024
1c480dc
mv docker
pcrespov Aug 28, 2024
bcaaf49
mv license to root
pcrespov Aug 28, 2024
d5b1be2
tests
pcrespov Aug 28, 2024
17a7006
cleanup testing and doc setup
pcrespov Aug 28, 2024
5a0ec4e
installs requirements
pcrespov Aug 28, 2024
55d8492
installs uv
pcrespov Aug 28, 2024
71be6a8
uv in makefile
pcrespov Aug 28, 2024
8198f3c
udpating tests
pcrespov Aug 28, 2024
c56a290
fixes asyncio mode
pcrespov Aug 28, 2024
bacc756
test/test_osparc passes
pcrespov Aug 28, 2024
f0e01a9
fixes wrong requriements path
pcrespov Aug 28, 2024
931abe4
fixes test for 3.8
pcrespov Aug 28, 2024
f671563
fixes installations
pcrespov Aug 28, 2024
d75943f
@sanderegg review: uv and constraint
pcrespov Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/build-python-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,27 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.10.14
- name: install uv
uses: yezz123/setup-uv@v4
- name: Setup Python environment
run: |
git status
make devenv
source .venv/bin/activate
- name: Process tag
- name: Git tag to VERSION
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: |
source .venv/bin/activate
version=$(echo ${{ github.ref }} | grep -oP '(?<=refs/tags/v)\d+\.\d+\.\d+')
python scripts/is_semantic_version.py "${version}"
echo "${version}" > clients/python/client/VERSION
- name: Generate client
echo "${version}" > clients/python/VERSION
- name: Auto-generate python_client and build distributions
run: |
source .venv/bin/activate
cd clients/python
make install-dev
make dist-ci
uv pip install -r requirements/dev.txt
make python-client
make dist
- name: Set variables
id: variables
run: |
Expand Down Expand Up @@ -70,6 +73,8 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install uv
uses: yezz123/setup-uv@v4
- name: Pip cache
uses: actions/cache@v3
with:
Expand All @@ -90,6 +95,7 @@ jobs:
python -m pip install clients/python/artifacts/dist/${{needs.build.outputs.osparc}} --find-links=clients/python/artifacts/dist
cd clients/python
make install-unit-test
pip list | grep osparc
pytest -v --ignore=/artifacts/client --ignore=test/e2e

test-latest:
Expand All @@ -106,6 +112,8 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install uv
uses: yezz123/setup-uv@v4
- name: Pip cache
uses: actions/cache@v3
with:
Expand All @@ -122,8 +130,8 @@ jobs:
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install pytest
python -m pip install clients/python/artifacts/dist/${{needs.build.outputs.osparc}} --find-links=clients/python/artifacts/dist
uv pip install pytest
uv pip install clients/python/artifacts/dist/${{needs.build.outputs.osparc}} --find-links=clients/python/artifacts/dist
cd clients/python
make install-unit-test
pytest -v --ignore=/artifacts/client --ignore=test/e2e
Expand Down
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ tmp*

# auto generated python code
/clients/python/artifacts/*
/clients/python/client/build/*
/clients/python/client/osparc/data/openapi.json
/clients/python/src/build/*
/clients/python/src/osparc/data/openapi.json
/clients/python/VERSION
/clients/python/test/e2e/pytest.ini
/clients/python/client/VERSION


# key-words in filename to ignore them
*secret*
*ignore*
!.dockerignore
!.gitignore
13 changes: 5 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ repos:
types: ["file"]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.282
rev: v0.6.2
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
args:
- --fix
- --exit-non-zero-on-fix
- id: ruff-format
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
Expand Down
34 changes: 34 additions & 0 deletions .vscode/launch.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Run Test",
"type": "debugpy",
"request": "launch",
"module": "pytest",
"args": [
"--ff",
"--log-cli-level=INFO",
"--pdb",
"--setup-show",
"-sx",
"-vv",
"--asyncio-mode=auto",
"${file}"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"justMyCode": false
}
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.template.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{
"files.associations": {
".*rc": "ini",
".env*": "ini",
"**/requirements/*.in": "pip-requirements",
"**/requirements/*.txt": "pip-requirements",
"*logs.txt": "log",
"*.logs*": "log",
"*Makefile": "makefile",
"docker-compose*.yml": "dockercompose",
"Dockerfile*": "dockerfile"
},
"pylint.args": [
"--rcfile=clients/python/.pylintrc"
]
Expand Down
File renamed without changes.
50 changes: 21 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ include ./scripts/common.Makefile

PYTHON_DIR := $(CLIENTS_DIR)/python


.vscode/%.json: .vscode/%.template.json
$(if $(wildcard $@), \
@echo "WARNING ##### $< is newer than $@ ####"; diff -uN $@ $<; false;,\
@echo "WARNING ##### $@ does not exist, cloning $< as $@ ############"; cp $< $@)


.PHONY: info
info: ## general information
# system
Expand All @@ -13,30 +20,32 @@ info: ## general information
@which python
@pip list
# API
@echo ' title : ' $(shell bash $(SCRIPTS_DIR)/jq.bash -r .info.title $(REPO_ROOT)/api/openapi.json)
@echo ' version : ' $(shell bash $(SCRIPTS_DIR)/jq.bash -r .info.version $(REPO_ROOT)/api/openapi.json)
@echo ' title : $(shell bash $(SCRIPTS_DIR)/jq.bash -r .info.title $(REPO_ROOT)/api/openapi.json)'
@echo ' version : $(shell bash $(SCRIPTS_DIR)/jq.bash -r .info.version $(REPO_ROOT)/api/openapi.json)'
# nox
@echo nox --list-session


.venv:
@python3 --version
python3 -m venv $@
.venv: .check-uv-installed
@uv venv $@
## upgrading tools to latest version in $(shell python3 --version)
$@/bin/pip3 --quiet install --upgrade \
pip \
@uv pip --quiet install --upgrade \
pip~=24.0 \
wheel \
setuptools
@$@/bin/pip3 list --verbose
setuptools \
uv
@uv pip list


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



## VERSION -------------------------------------------------------------------------------

.PHONY: version-patch version-minor version-major
Expand All @@ -53,6 +62,7 @@ define _bumpversion
endef

## DOCUMENTATION ------------------------------------------------------------------------

.PHONY: http-doc docs
docs: ## generate docs
# generate documentation
Expand All @@ -69,21 +79,3 @@ http-doc: docs ## generates and serves doc
# starting doc website
@echo "Check site on http://127.0.0.1:50001/"
python3 -m http.server 50001 --bind 127.0.0.1

## CLEAN -------------------------------------------------------------------------------

.PHONY: clean-hooks
clean-hooks: ## Uninstalls git pre-commit hooks
@-pre-commit uninstall 2> /dev/null || rm .git/hooks/pre-commit

_git_clean_args := -dx --force --exclude=.vscode --exclude=TODO.md --exclude=.venv --exclude=.python-version --exclude="*keep*"

.check-clean:
@git clean -n $(_git_clean_args)
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
@echo -n "$(shell whoami), are you REALLY sure? [y/N] " && read ans && [ $${ans:-N} = y ]


clean: .check-clean ## cleans all unversioned files in project and temp files create by this makefile
# Cleaning unversioned
@git clean $(_git_clean_args)
Loading
Loading