Thin Python client for the NetGreener HTTP API (auth, run sessions, surrogate training).
Project description
netgreener_sdk
Thin Python client for the NetGreener HTTP API (/api/v1).
Full handbook (CLI + VS Code + SDK + CI):
../docs/PROGRAMMER_BOOKLET.mdSame contracts asapi_serverrouters; paths mirrornetgreener_cli/netgreener/api_client.pywith extra/featurescoverage.
Install
From the repo (editable):
pip install -e ./netgreener_sdk
Requires Python 3.10+ and requests.
Quick start
from netgreener_sdk import NetGreenerClient, APIError
client = NetGreenerClient(base_url="http://localhost:8000/api/v1")
client.login(email="you@example.com", password="…")
me = client.get_me()
print(me["email"])
# Project feature metadata (Parquet / path pointer)
row = client.post_project_feature_metadata(
1,
{"parquet_path": "/data/features.parquet", "feature_version": 1},
)
# Repo-aware project (git_url match order mirrors CLI)
project = client.get_or_create_project(
"My ML repo",
"/work/my-ml",
git_url="https://github.com/acme/my-ml.git",
)
# Report AI summary credit quote (Phase 8d)
quote = client.quote_report_ai_summary(
org_id=1,
payload={
"template": "sustainability",
"scope_type": "org",
"period_config": {
"primary": {"from": "2026-04-01", "to": "2026-04-30"},
"comparisons": [],
},
},
)
print(quote["total_credits"])
# Generate and download (Phase 8 SDK P2)
result = client.generate_report(
1,
{
"template": "sustainability",
"scope_type": "org",
"period_config": {
"primary": {"from": "2026-04-01", "to": "2026-04-30"},
"comparisons": [],
},
"output_format": "both",
},
)
report_id = result["report"]["report_id"]
pdf_bytes = client.download_report(1, report_id, format="pdf")
Base URL
Pass the API root including /api/v1, e.g. https://your-host/api/v1.
Auth
login(email, password); sets the bearer token on the client; response includesuser,access_token,expires_in.set_token(token); use an existing JWT.get_access_token(); current token orNone.get_me();GET /auth/me(requires valid token).
Feature metadata writes on the server require developer or admin; GET requires project access.
Projects & reports (Phase 3b)
| Method | HTTP |
|---|---|
get_projects |
GET /projects |
create_project |
POST /projects |
update_project |
PUT /projects/{id} |
get_or_create_project |
list + match by git_url → directory → name; create or sync |
quote_report_ai_summary |
POST /organizations/{org_id}/reports/ai-summary/quote |
preview_report / generate_report |
POST .../reports/preview / .../generate |
get_report_history / download_report |
GET .../history / .../{report_id}/download |
get_report_settings / update_report_settings |
schedule + cost assumptions |
run_scheduled_report_now |
POST .../reports/schedule/run-now |
Local analyze (--paths, analyze_local) stays in the netgreener CLI package, not the SDK.
See also
docs/CODEANALYZER_TO_API_SURFACE.md; which endpoints exist and how they map to CodeAnalyzer outputs.docs/PLAN_INDEX.md; full product/engineering plan checklist.
Tests
From repo root:
python -m pytest netgreener_sdk/tests -q
Publish (CI)
Same PyPI token as the CLI — Azure Library group Package_credential, secret PYPI_API_TOKEN, must allow upload to both netgreener and netgreener_sdk.
Different pipeline and tag (not the CLI pipeline):
| Package | Pipeline | Git tag | PyPI name |
|---|---|---|---|
| CLI | azure-pipelines-cli-publish.yml |
cli-v*.*.* |
netgreener |
| SDK | azure-pipelines-sdk-publish.yml |
sdk-v*.*.* |
netgreener_sdk |
Example SDK release: git tag sdk-v0.1.0 && git push origin sdk-v0.1.0
Pre-publish local build (recommended)
Before pushing the sdk-v... tag, verify the wheel/sdist build is clean:
python -m pip install --upgrade pip
python -m pip install build twine
python -m build netgreener_sdk
python -m twine check netgreener_sdk/dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netgreener_sdk-0.1.1.tar.gz.
File metadata
- Download URL: netgreener_sdk-0.1.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
549998771cce171c7f3a1bff0147159fd1d2902d0cfb6df0c545955e8c9c461d
|
|
| MD5 |
82c667ed980a34dfc8e08dcede42c45c
|
|
| BLAKE2b-256 |
c455f8f096fbfc8ccf1e48462528aadd5d5ddb364ff84e3cfe4f3beeab32967e
|
File details
Details for the file netgreener_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: netgreener_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69cd2ac977d723ebeb33d3ca8ebc95eafde139c8ff61db724f17e0d954070da4
|
|
| MD5 |
5089fffa0ae680ab63f8e9f09e20f63d
|
|
| BLAKE2b-256 |
9ca301a54cdee687c4c3ed5cd66634ec10121fc89c1a012f11ae70257dee4102
|