Skip to content

Make use of poetry #122

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

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
poetry.lock
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ updates:
- "*" # Update all packages together
exclude-patterns:
- "opentelemetry*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
github-actions:
patterns:
- "*"

21 changes: 12 additions & 9 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox
- name: Test with tox
run: tox -e style
pip install poetry
poetry install --all-extras --all-groups

- name: Run pre-commit
run: |
poetry run pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )

tests:
uses: ./.github/workflows/tests.yml
Expand Down Expand Up @@ -72,12 +76,11 @@ jobs:
- name: Install dependencies and build the library
id: wheels
run: |
python -m pip install --upgrade pip setuptools
python -m pip install -r requirements/requirements_build.txt
python build.py dev
python build.py wheels
python -m twine check dist/*
version=$(ls dist/ | grep ansys_hps_data_transfer_client | grep -E -o "[0-9]+.[0-9]+.[0-9]+")
pip install poetry
poetry install --all-extras --all-groups
poetry build
poetry run python -m twine check dist/*
version=$(ls dist/ | grep whl | grep -E -o "[0-9]+.[0-9]+.[0-9]+")
echo "version=$version" >> $GITHUB_OUTPUT
echo "Version: $version"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generate_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:

- name: Create venv
run: |
python3 -m venv dev_env
dev_env/bin/python build.py dev
pip install poetry
poetry install --all-extras --all-groups

- name: Generate models
run: |
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
matrix:
os: [ubuntu-latest-8-cores]
cfg:
- {python-version: "3.10", toxenv: "py310"}
- {python-version: "3.12", toxenv: "py312"}
- {python-version: "3.10"}
- {python-version: "3.12"}
- {python-version: "3.13"}
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -48,7 +49,8 @@ jobs:

- name: Install dependencies
run: |
python build.py dev
pip install poetry
poetry install --all-extras --all-groups

- name: Start containers
run: |
Expand All @@ -57,7 +59,7 @@ jobs:

- name: Run tests
run: |
python build.py tests
poetry run pytest .

- name: Stop containers
if: always()
Expand Down
15 changes: 8 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ repos:
rev: v2.1.0
hooks:
- id: codespell
# exclude: >
# (?x)^(
# .*\.dat|
# .*\.mac|
# .*\.k
# )$
# args: [-I, .codespellignore, --ignore-long-lines]
exclude: >
(?x)^(
.*\.dat|
.*\.mac|
.*\.lock|
.*\.k
)$
#args: [-I, .codespellignore]

# For now we disable some of these checks, can be reenabled later
# - repo: https://github.com/pycqa/pydocstyle
Expand Down
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,25 @@ Python client library for HPS Data Transfer Service

### Prerequisites

Install pre-commit in your `global` python using
Install poetry globally

```
python -m pip install pre-commit
python -m pip install poetry
```
### Setup Environment

#### Linux:

```
python3 -m venv dev_env
source dev_env/bin/activate
python build.py dev
```
#### Windows:
```
python3 -m venv dev_env
dev_env/Scripts/activate
python build.py dev
poetry install --all-groups --all-extras
```

### Build
### Build wheels
```
python build.py dist
poetry build
```

### Test
```
python build.py tests
poetry run pytest .
```

### Generate Models
Expand Down
Empty file added README_whl.md
Empty file.
6 changes: 6 additions & 0 deletions ansys/hps/data_transfer/client/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import threading
import time

import humanfriendly
import portend

from .exceptions import BinaryError
Expand Down Expand Up @@ -179,6 +180,10 @@ def stop(self, wait=5.0):
if self._process is None:
return

if self._process.poll() is not None:
log.debug("Worker already stopped")
return

log.debug("Stopping worker ...")
self._stop.set()
self._prepared.clear()
Expand All @@ -192,6 +197,7 @@ def stop(self, wait=5.0):
self._process.kill()
break
time.sleep(wait * 0.1)
log.debug(f"Worker stopped after {humanfriendly.format_timespan(time.time() - start)}")

def args_str(self):
return " ".join(self._args)
Expand Down
2 changes: 1 addition & 1 deletion ansys/hps/data_transfer/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def mark_ready(self, ready):
self._ok_reported = True
else:
self._ok_reported = False
log.warning(msg)
log.info(msg)

def mark_failed(self, exc=None, binary=None):
exc_str = "" if exc is None else f": {exc}"
Expand Down
161 changes: 0 additions & 161 deletions build.py

This file was deleted.

2 changes: 1 addition & 1 deletion config
4 changes: 2 additions & 2 deletions generate_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
-g openapi \
-o /local/out --skip-validate-spec

dev_env/bin/datamodel-codegen --input ./out/openapi.json --input-file-type openapi --output ansys/hps/data_transfer/client/models --output-model-type pydantic_v2.BaseModel --custom-file-header "# generated by datamodel-codegen"
poetry run datamodel-codegen --input ./out/openapi.json --input-file-type openapi --output ansys/hps/data_transfer/client/models --output-model-type pydantic_v2.BaseModel --custom-file-header "# generated by datamodel-codegen"

sed_cmd=sed

Expand All @@ -26,7 +26,7 @@ popd
for i in {1..10}
do
echo "Running $i iteration"
dev_env/bin/pre-commit run --all-files
poetry run pre-commit run --all-files
if [ $? -eq 0 ]
then
break
Expand Down
Loading