Skip to content

Commit bb2fd8a

Browse files
committed
Added Wellbore ddms
1 parent 7eb795d commit bb2fd8a

File tree

5 files changed

+11744
-0
lines changed

5 files changed

+11744
-0
lines changed

.github/copilot-instructions.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# OSDU Python Client
2+
3+
## Build, test, and lint commands
4+
5+
```bash
6+
uv sync --all-extras
7+
uv run ruff check .
8+
uv build
9+
uv run pytest tests -q
10+
uv run pytest tests/search_test.py::test_search_query_records -q
11+
```
12+
13+
Integration tests depend on a repo-root `.env` loaded by `tests/config.py` and use MSAL interactive login from `tests/auth_fixture.py`. Tokens are cached in `.msal_token_cache.bin` by default, or at `OSDU_MSAL_CACHE_PATH` if set.
14+
15+
Useful repository-specific maintenance commands:
16+
17+
```bash
18+
uv run python download.py
19+
uv run python fix_openapi_json_response_media_types.py --check
20+
uv run python fix_openapi_json_response_media_types.py
21+
uv run python generate_all.py
22+
```
23+
24+
## High-level architecture
25+
26+
This repository is organized around OpenAPI-driven client generation rather than handwritten runtime code.
27+
28+
- `openapi_specs/*.json` are the source inputs for each OSDU service.
29+
- `download.py` fetches the OSDU Core Services wiki, extracts service doc links, normalizes `swagger-ui`/`/docs` URLs to JSON spec endpoints, and downloads specs with provider fallbacks (`ci`, `azure`, `aws`, `gc`).
30+
- `fix_openapi_json_response_media_types.py` patches a recurring upstream issue where structured JSON responses are declared under `*/*` instead of `application/json`. It only rewrites 2xx responses whose schemas resolve to structured payloads.
31+
- `generate_all.py` regenerates `src/osdu_python_client/<service>/` for every spec. It also patches missing `info.version` values before invoking `openapi-python-client`.
32+
33+
Generated service packages follow the same shape:
34+
35+
- `client.py` defines `Client` and `AuthenticatedClient`.
36+
- `api/` contains per-endpoint modules with `_get_kwargs`, `_parse_response`, `sync_detailed`, `sync`, `asyncio_detailed`, and `asyncio`.
37+
- `models/` contains generated request/response DTOs.
38+
- `types.py` and `errors.py` provide shared response wrappers and error handling.
39+
40+
The handwritten test layer in `tests/` is the main example of intended usage. `tests/config.py` builds service URLs from a single `server` plus `*_endpoint` settings, `tests/auth_fixture.py` acquires an Azure access token with MSAL, and tests instantiate a service-specific `AuthenticatedClient` before calling generated endpoint functions and inspecting `result.parsed`.
41+
42+
## Key conventions
43+
44+
- Treat `src/osdu_python_client/` as generated output. Prefer changing `openapi_specs/`, `download.py`, `fix_openapi_json_response_media_types.py`, or `generate_all.py`, then regenerate.
45+
- When running tests, target `tests/` explicitly. Running `pytest` from the repo root also discovers generated `test_*.py` modules under `src/osdu_python_client/register/`, which produces collection warnings unrelated to the handwritten test suite.
46+
- Service package names come from spec filenames normalized to lowercase with spaces/hyphens converted to underscores, e.g. `Ingestion_Workflow_Service.json` becomes `osdu_python_client.ingestion_workflow_service`.
47+
- Repository tests are integration tests against a live OSDU environment, not isolated unit tests. Expect real network calls, `data_partition_id` headers, and interactive authentication if no cached MSAL token is available.
48+
- Generated endpoint helpers usually return a `Response[...]` wrapper from `sync_detailed(...)`; the parsed DTO is available on `.parsed`. Existing tests assert on `result.status_code.value` and then work with `result.parsed`.

.github/workflows/build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build library
2+
3+
on:
4+
push:
5+
tags-ignore:
6+
- "v*"
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.13"
25+
26+
- name: Set up uv
27+
uses: astral-sh/setup-uv@v6
28+
with:
29+
enable-cache: true
30+
31+
- name: Sync dependencies
32+
run: uv sync --all-extras --frozen
33+
34+
- name: Lint
35+
run: uv run ruff check .
36+
37+
- name: Build distributions
38+
run: uv build
39+
40+
- name: Upload build artifacts
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: python-package-distributions
44+
path: dist/*

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release library
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.13"
22+
23+
- name: Set up uv
24+
uses: astral-sh/setup-uv@v6
25+
with:
26+
enable-cache: true
27+
28+
- name: Sync dependencies
29+
run: uv sync --all-extras --frozen
30+
31+
- name: Lint
32+
run: uv run ruff check .
33+
34+
- name: Validate tag matches package version
35+
run: |
36+
VERSION="$(uv run python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
37+
TAG_VERSION="${GITHUB_REF_NAME#v}"
38+
39+
if [ "$TAG_VERSION" != "$VERSION" ]; then
40+
echo "Tag version ($TAG_VERSION) does not match pyproject version ($VERSION)."
41+
exit 1
42+
fi
43+
44+
- name: Build distributions
45+
run: uv build
46+
47+
- name: Upload build artifacts
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: python-package-distributions
51+
path: dist/*
52+
53+
github-release:
54+
needs: build
55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: write
58+
59+
steps:
60+
- name: Download build artifacts
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: python-package-distributions
64+
path: dist
65+
66+
- name: Create GitHub release
67+
uses: softprops/action-gh-release@v2
68+
with:
69+
files: dist/*
70+
generate_release_notes: true

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ The following services are currently generated:
126126
- `search`
127127
- `storage`
128128
- `unit`
129+
- `wellbore_ddms`
129130

130131
## Development
131132

@@ -177,6 +178,26 @@ This command runs `generate_all.py`, which iterates through the JSON files and u
177178

178179
Warning: do not hand-edit files under `src/osdu_python_client/`. They are generated artifacts and your changes will be overwritten the next time `uv run python generate_all.py` is run. Make changes in `openapi_specs/` and/or the generation scripts instead.
179180

181+
### Releasing
182+
183+
GitHub Actions includes two workflows:
184+
185+
- `.github/workflows/build.yml` runs on pushes and pull requests and verifies linting plus package build.
186+
- `.github/workflows/release.yml` runs only for tags matching `v*`, rebuilds the package, verifies the tag matches `project.version` in `pyproject.toml`, and creates a GitHub release with the built distributions attached.
187+
188+
Release flow:
189+
190+
1. Update `project.version` in `pyproject.toml`.
191+
2. Commit and push that change to the default branch.
192+
3. Create and push a matching version tag:
193+
194+
```bash
195+
git tag v0.1.0
196+
git push origin v0.1.0
197+
```
198+
199+
If the tag does not match the version in `pyproject.toml`, the release workflow fails before publishing release artifacts.
200+
180201
## Project Structure
181202

182203
- `openapi_specs/`: Contains the downloaded OpenAPI JSON specifications.

0 commit comments

Comments
 (0)