Skip to content

Commit 046719d

Browse files
authored
Merge pull request #8 from rdmorganiser/dev
Add pyproject.toml, remove setup.py, add pre-commit and fix stuff, and add ci
2 parents 1400639 + 4543939 commit 046719d

22 files changed

+277
-89
lines changed

.github/workflows/ci.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
paths:
9+
- '.github/workflows/**'
10+
- 'rdmo_client/**'
11+
- 'testing/**'
12+
- 'notebooks/**'
13+
- '.pre-commit-config.yaml'
14+
- 'pyproject.toml'
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
env:
21+
PYTHONDONTWRITEBYTECODE: 1
22+
FORCE_COLOR: 1
23+
24+
jobs:
25+
lint:
26+
uses: rdmorganiser/.github/.github/workflows/_lint.yml@main
27+
28+
build-wheel:
29+
name: Build Python Wheel
30+
runs-on: ubuntu-24.04
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v5
36+
with:
37+
enable-cache: true
38+
cache-dependency-glob: "pyproject.toml"
39+
40+
- name: Set up Python
41+
run: uv python install
42+
43+
- name: Install dependencies
44+
run: uv sync --all-extras --dev
45+
46+
- name: Build the wheel
47+
run: uv build
48+
49+
- name: Check wheel metadata
50+
run: uvx twine check --strict dist/*
51+
52+
- name: Install package from built wheel
53+
run: uv pip install --no-compile dist/rdmo_client*.whl
54+
55+
- name: Write info to step summary
56+
run: |
57+
{
58+
echo -e "# ✓ Wheel successfully built\n\n"
59+
echo '<details><summary>Information about installed wheel</summary>'
60+
echo -e "\n\`\`\`console"
61+
echo "$ uv pip show --files --verbose rdmo_client"
62+
uv pip show --files --verbose rdmo_client
63+
echo -e "\`\`\`\n</details>"
64+
} >> $GITHUB_STEP_SUMMARY
65+
66+
- name: Upload wheel as artifact
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: wheel
70+
path: dist/rdmo_client*.whl
71+
if-no-files-found: error
72+
retention-days: 30
73+
74+
dev-setup:
75+
name: "Import rdmo_client on ${{ matrix.os }} with ${{ matrix.python-version }}"
76+
needs: build-wheel
77+
runs-on: ${{ matrix.os }}
78+
strategy:
79+
matrix:
80+
os: [ubuntu-latest, windows-latest, macos-latest]
81+
python-version:
82+
- "3.9"
83+
- "3.12"
84+
steps:
85+
- uses: actions/checkout@v4
86+
87+
- name: Install uv
88+
uses: astral-sh/setup-uv@v5
89+
with:
90+
python-version: ${{ matrix.python-version }}
91+
enable-cache: true
92+
cache-dependency-glob: "pyproject.toml"
93+
94+
- name: Download built wheel
95+
uses: actions/download-artifact@v4
96+
with:
97+
name: wheel
98+
path: dist
99+
100+
- name: Install package from built wheel
101+
run: uv pip install --no-compile "$(ls dist/rdmo_client*none-any.whl)"
102+
103+
- name: Check version
104+
run: uv run --no-project -- python -c "import rdmo_client; print(rdmo_client.__version__)"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env*
1111
build
1212
dist
1313
*.egg-info
14+
_version.py
1415

1516
.ipynb_checkpoints
1617
test*

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: meta
3+
hooks:
4+
- id: check-hooks-apply
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v5.0.0
7+
hooks:
8+
- id: check-ast
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
- id: debug-statements
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.9.7
14+
hooks:
15+
- id: ruff
16+
args: [--fix, --exit-non-zero-on-fix]
17+
- repo: https://github.com/crate-ci/typos
18+
rev: v1.29.9
19+
hooks:
20+
- id: typos

notebooks/conditions.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9+
"from rdmo_client import Client\n",
10+
"\n",
911
"BASE_URL = 'http://localhost:8000'\n",
1012
"AUTH = ('admin', 'admin')\n",
1113
"TOKEN = '8bd704f41e0def27e0406e5ae8ec479ce575aa8f'\n",
1214
"URI_PREFIX = 'https://rdmorganiser.github.io/terms/'\n",
1315
"\n",
14-
"from rdmo_client import Client\n",
1516
"client = Client(BASE_URL, auth=AUTH)"
1617
]
1718
},
@@ -30,13 +31,13 @@
3031
"metadata": {},
3132
"outputs": [],
3233
"source": [
33-
"client.resolve_condition(13)"
34+
"client.retrieve_condition(13)"
3435
]
3536
}
3637
],
3738
"metadata": {
3839
"kernelspec": {
39-
"display_name": "Python 3",
40+
"display_name": "Python 3 (ipykernel)",
4041
"language": "python",
4142
"name": "python3"
4243
},
@@ -50,7 +51,7 @@
5051
"name": "python",
5152
"nbconvert_exporter": "python",
5253
"pygments_lexer": "ipython3",
53-
"version": "3.7.3"
54+
"version": "3.13.1"
5455
}
5556
},
5657
"nbformat": 4,

notebooks/domain.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9+
"from rdmo_client import Client\n",
10+
"\n",
911
"BASE_URL = 'http://localhost:8000'\n",
1012
"AUTH = ('admin', 'admin')\n",
1113
"TOKEN = '8bd704f41e0def27e0406e5ae8ec479ce575aa8f'\n",
1214
"URI_PREFIX = 'https://rdmorganiser.github.io/terms/'\n",
1315
"\n",
14-
"from rdmo_client import Client\n",
1516
"client = Client(BASE_URL, auth=AUTH)"
1617
]
1718
},
@@ -21,13 +22,13 @@
2122
"metadata": {},
2223
"outputs": [],
2324
"source": [
24-
"client.nest_attributes()"
25+
"client.nest_attributes(1)"
2526
]
2627
}
2728
],
2829
"metadata": {
2930
"kernelspec": {
30-
"display_name": "Python 3",
31+
"display_name": "Python 3 (ipykernel)",
3132
"language": "python",
3233
"name": "python3"
3334
},
@@ -41,7 +42,7 @@
4142
"name": "python",
4243
"nbconvert_exporter": "python",
4344
"pygments_lexer": "ipython3",
44-
"version": "3.7.3"
45+
"version": "3.13.1"
4546
}
4647
},
4748
"nbformat": 4,

notebooks/options.ipynb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9+
"from rdmo_client import Client\n",
10+
"\n",
911
"BASE_URL = 'http://localhost:8000'\n",
1012
"AUTH = ('api', 'api')\n",
1113
"TOKEN = '8bd704f41e0def27e0406e5ae8ec479ce575aa8f'\n",
1214
"URI_PREFIX = 'https://rdmorganiser.github.io/terms/'\n",
1315
"\n",
14-
"from rdmo_client import Client\n",
1516
"client = Client(BASE_URL, auth=AUTH)"
1617
]
1718
},
@@ -41,7 +42,7 @@
4142
"source": [
4243
"optionset = client.create_optionset({\n",
4344
" 'uri_prefix': URI_PREFIX,\n",
44-
" 'key': 'new',\n",
45+
" 'uri_path': 'new',\n",
4546
" 'order': 666,\n",
4647
"})"
4748
]
@@ -53,13 +54,13 @@
5354
"outputs": [],
5455
"source": [
5556
"for i in range(5):\n",
56-
" key = 'new-%.2i' % i\n",
57-
" \n",
57+
" uri_path = f'new-{i:02}'\n",
58+
"\n",
5859
" client.create_option({\n",
5960
" 'uri_prefix': URI_PREFIX,\n",
60-
" 'key': key,\n",
61+
" 'uri_path': uri_path,\n",
6162
" 'order': i,\n",
62-
" 'optionset': optionset['id'] \n",
63+
" 'optionset': optionset['id']\n",
6364
" })"
6465
]
6566
},
@@ -71,8 +72,8 @@
7172
"source": [
7273
"for option in client.list_options(optionset=optionset['id']):\n",
7374
" option.update({\n",
74-
" 'text_en': option['key'] + '-en',\n",
75-
" 'text_de': option['key'] + '-de'\n",
75+
" 'text_en': option['uri_path'] + '-en',\n",
76+
" 'text_de': option['uri_path'] + '-de'\n",
7677
" })\n",
7778
" client.update_option(option['id'], option)"
7879
]
@@ -89,7 +90,7 @@
8990
],
9091
"metadata": {
9192
"kernelspec": {
92-
"display_name": "Python 3",
93+
"display_name": "Python 3 (ipykernel)",
9394
"language": "python",
9495
"name": "python3"
9596
},
@@ -103,7 +104,7 @@
103104
"name": "python",
104105
"nbconvert_exporter": "python",
105106
"pygments_lexer": "ipython3",
106-
"version": "3.7.3"
107+
"version": "3.13.1"
107108
}
108109
},
109110
"nbformat": 4,

notebooks/projects.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9+
"from rdmo_client import Client\n",
10+
"\n",
911
"BASE_URL = 'http://localhost:8000'\n",
1012
"AUTH = ('api', 'api')\n",
1113
"TOKEN = '8bd704f41e0def27e0406e5ae8ec479ce575aa8f'\n",
1214
"URI_PREFIX = 'https://rdmorganiser.github.io/terms/'\n",
1315
"\n",
14-
"from rdmo_client import Client\n",
1516
"client = Client(BASE_URL, auth=AUTH)"
1617
]
1718
},
@@ -68,14 +69,15 @@
6869
"source": [
6970
"client.create_project({\n",
7071
" 'user': 1,\n",
72+
" 'catalog': 1,\n",
7173
" 'title': 'FOO'\n",
7274
"})"
7375
]
7476
}
7577
],
7678
"metadata": {
7779
"kernelspec": {
78-
"display_name": "Python 3",
80+
"display_name": "Python 3 (ipykernel)",
7981
"language": "python",
8082
"name": "python3"
8183
},
@@ -89,7 +91,7 @@
8991
"name": "python",
9092
"nbconvert_exporter": "python",
9193
"pygments_lexer": "ipython3",
92-
"version": "3.7.3"
94+
"version": "3.13.1"
9395
}
9496
},
9597
"nbformat": 4,

notebooks/questions.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9+
"from rdmo_client import Client\n",
10+
"\n",
911
"BASE_URL = 'http://localhost:8000'\n",
1012
"AUTH = ('admin', 'admin')\n",
1113
"TOKEN = '8bd704f41e0def27e0406e5ae8ec479ce575aa8f'\n",
1214
"URI_PREFIX = 'https://rdmorganiser.github.io/terms/'\n",
1315
"\n",
14-
"from rdmo_client import Client\n",
1516
"client = Client(BASE_URL, auth=AUTH)"
1617
]
1718
},
@@ -54,7 +55,7 @@
5455
],
5556
"metadata": {
5657
"kernelspec": {
57-
"display_name": "Python 3",
58+
"display_name": "Python 3 (ipykernel)",
5859
"language": "python",
5960
"name": "python3"
6061
},
@@ -68,7 +69,7 @@
6869
"name": "python",
6970
"nbconvert_exporter": "python",
7071
"pygments_lexer": "ipython3",
71-
"version": "3.7.3"
72+
"version": "3.13.1"
7273
}
7374
},
7475
"nbformat": 4,

notebooks/tasks.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9+
"from rdmo_client import Client\n",
10+
"\n",
911
"BASE_URL = 'http://localhost:8000'\n",
1012
"AUTH = ('admin', 'admin')\n",
1113
"TOKEN = '8bd704f41e0def27e0406e5ae8ec479ce575aa8f'\n",
1214
"URI_PREFIX = 'https://rdmorganiser.github.io/terms/'\n",
1315
"\n",
14-
"from rdmo_client import Client\n",
1516
"client = Client(BASE_URL, auth=AUTH)"
1617
]
1718
},
@@ -27,7 +28,7 @@
2728
],
2829
"metadata": {
2930
"kernelspec": {
30-
"display_name": "Python 3",
31+
"display_name": "Python 3 (ipykernel)",
3132
"language": "python",
3233
"name": "python3"
3334
},
@@ -41,7 +42,7 @@
4142
"name": "python",
4243
"nbconvert_exporter": "python",
4344
"pygments_lexer": "ipython3",
44-
"version": "3.7.3"
45+
"version": "3.13.1"
4546
}
4647
},
4748
"nbformat": 4,

0 commit comments

Comments
 (0)