hensynth 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hensynth-0.1.0/LICENSE +26 -0
- hensynth-0.1.0/PKG-INFO +96 -0
- hensynth-0.1.0/README.md +66 -0
- hensynth-0.1.0/hensynth/__init__.py +15 -0
- hensynth-0.1.0/hensynth/client.py +242 -0
- hensynth-0.1.0/hensynth.egg-info/PKG-INFO +96 -0
- hensynth-0.1.0/hensynth.egg-info/SOURCES.txt +11 -0
- hensynth-0.1.0/hensynth.egg-info/dependency_links.txt +1 -0
- hensynth-0.1.0/hensynth.egg-info/requires.txt +6 -0
- hensynth-0.1.0/hensynth.egg-info/top_level.txt +1 -0
- hensynth-0.1.0/pyproject.toml +39 -0
- hensynth-0.1.0/setup.cfg +4 -0
- hensynth-0.1.0/tests/test_client_basic.py +30 -0
hensynth-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
LicenseRef-Proprietary
|
|
2
|
+
|
|
3
|
+
HENSYNTH Python SDK (HS-SDK-001)
|
|
4
|
+
Copyright (c) HENDOI TECHNOLOGIES PRIVATE LIMITED. All rights reserved.
|
|
5
|
+
|
|
6
|
+
This software and associated documentation files (the "Software") are the
|
|
7
|
+
proprietary property of HENDOI TECHNOLOGIES PRIVATE LIMITED ("HENDOI").
|
|
8
|
+
|
|
9
|
+
Permission to use the Software is granted only under a valid HENDOI
|
|
10
|
+
subscription, agreement, or other written authorization from HENDOI, and
|
|
11
|
+
solely for interacting with HENSYNTH / HENDOI services as permitted by that
|
|
12
|
+
authorization.
|
|
13
|
+
|
|
14
|
+
You may not copy, modify, merge, publish, distribute, sublicense, sell,
|
|
15
|
+
rent, lease, reverse engineer (except to the limited extent that applicable
|
|
16
|
+
law forbids this restriction), or otherwise exploit the Software except as
|
|
17
|
+
expressly allowed by HENDOI in writing.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
22
|
+
HENDOI OR ITS LICENSORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
|
23
|
+
LIABILITY ARISING FROM USE OF THE SOFTWARE.
|
|
24
|
+
|
|
25
|
+
Contact: support@hendoi.com
|
|
26
|
+
Website: https://hendoi.com
|
hensynth-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hensynth
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official HENSYNTH Python SDK (HS-SDK-001) — aircraft / mission synthesis: projects, synthesize, analyze, mission, optimize, trade-study.
|
|
5
|
+
Author-email: HENDOI TECHNOLOGIES PRIVATE LIMITED <support@hendoi.com>
|
|
6
|
+
License-Expression: LicenseRef-Proprietary
|
|
7
|
+
Project-URL: Homepage, https://hensynth.hendoi.com
|
|
8
|
+
Project-URL: Documentation, https://api.hendoi.com/?doc=hensynth-overview
|
|
9
|
+
Project-URL: Product, https://hendoi.com/products/hensynth
|
|
10
|
+
Project-URL: Issues, https://hendoi.com/contact
|
|
11
|
+
Project-URL: PyPI, https://pypi.org/project/hensynth/
|
|
12
|
+
Keywords: hensynth,aerospace,MDO,HENDOI,SDK
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: requests>=2.28
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
27
|
+
Requires-Dist: build; extra == "dev"
|
|
28
|
+
Requires-Dist: twine; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# hensynth — Python SDK (HS-SDK-001)
|
|
32
|
+
|
|
33
|
+
Official headless HTTPS client for production [HENSYNTH](https://hensynth.hendoi.com). Same REST surface as the workspace.
|
|
34
|
+
|
|
35
|
+
**Version 0.1.0** · **Docs:** [https://api.hendoi.com/?doc=hensynth-overview](https://api.hendoi.com/?doc=hensynth-overview) · **Download:** [pypi.org/project/hensynth](https://pypi.org/project/hensynth/)
|
|
36
|
+
|
|
37
|
+
Header on every call: `X-Hensynth-Client: hensynth-python/0.1.0`.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install hensynth
|
|
43
|
+
# monorepo:
|
|
44
|
+
pip install -e hensynth-sdk/python
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Requires Python ≥ 3.9. License: **LicenseRef-Proprietary** (HENDOI).
|
|
48
|
+
|
|
49
|
+
## Auth
|
|
50
|
+
|
|
51
|
+
Create a `hsk_…` key on HENSYNTH → **Developers**. Keys do not cross products
|
|
52
|
+
(HENFOIL `hfk_`, HENSYNTH `hsk_`, HENMESH `hmk_`, HENFLOW `hfwk_`, HENSTRUCT `hstk_`).
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
export HENSYNTH_API_KEY=hsk_…
|
|
56
|
+
# optional: export HENSYNTH_API_URL=https://hensynth.hendoi.com
|
|
57
|
+
# local: export HENSYNTH_API_URL=http://localhost:8002
|
|
58
|
+
python -c "from hensynth import Client; print(Client().usage())"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## What it cannot claim
|
|
62
|
+
|
|
63
|
+
Not full-aircraft CFD certification, not a flight-manual authority, not a substitute for OEM loads / FAR/CS compliance.
|
|
64
|
+
|
|
65
|
+
## Client methods → REST
|
|
66
|
+
|
|
67
|
+
| Method | Route notes |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `usage` / `job` | `/usage` · `/jobs/:id` |
|
|
70
|
+
| `methods` | `GET /methods` |
|
|
71
|
+
| `projects` / `create_project` / `get_project` | `/projects*` |
|
|
72
|
+
| `synthesize` / `analyze` / `mission_run` | project runners |
|
|
73
|
+
| `optimize` / `sensitivity` / `trade_study` / `sweep` / `envelope` / `robust` | decide loop |
|
|
74
|
+
| `aircraft_import` / `aircraft_validate` / `aircraft_library` | aircraft ingest |
|
|
75
|
+
|
|
76
|
+
Long solves often return a job; methods with `await_job=True` (default) poll `GET /api/v1/jobs/:id`.
|
|
77
|
+
|
|
78
|
+
## Example
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from hensynth import Client
|
|
82
|
+
|
|
83
|
+
c = Client() # HENSYNTH_API_KEY
|
|
84
|
+
print(c.usage())
|
|
85
|
+
print(c.methods())
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Links
|
|
89
|
+
|
|
90
|
+
| | |
|
|
91
|
+
|---|---|
|
|
92
|
+
| **Download (PyPI)** | https://pypi.org/project/hensynth/ |
|
|
93
|
+
| Product | https://hensynth.hendoi.com |
|
|
94
|
+
| API docs | https://api.hendoi.com/?doc=hensynth-overview |
|
|
95
|
+
| Sister SDKs | `henfoil`, `hensynth`, `henmesh`, `henflow`, `henstruct` |
|
|
96
|
+
| Support | support@hendoi.com |
|
hensynth-0.1.0/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# hensynth — Python SDK (HS-SDK-001)
|
|
2
|
+
|
|
3
|
+
Official headless HTTPS client for production [HENSYNTH](https://hensynth.hendoi.com). Same REST surface as the workspace.
|
|
4
|
+
|
|
5
|
+
**Version 0.1.0** · **Docs:** [https://api.hendoi.com/?doc=hensynth-overview](https://api.hendoi.com/?doc=hensynth-overview) · **Download:** [pypi.org/project/hensynth](https://pypi.org/project/hensynth/)
|
|
6
|
+
|
|
7
|
+
Header on every call: `X-Hensynth-Client: hensynth-python/0.1.0`.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install hensynth
|
|
13
|
+
# monorepo:
|
|
14
|
+
pip install -e hensynth-sdk/python
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires Python ≥ 3.9. License: **LicenseRef-Proprietary** (HENDOI).
|
|
18
|
+
|
|
19
|
+
## Auth
|
|
20
|
+
|
|
21
|
+
Create a `hsk_…` key on HENSYNTH → **Developers**. Keys do not cross products
|
|
22
|
+
(HENFOIL `hfk_`, HENSYNTH `hsk_`, HENMESH `hmk_`, HENFLOW `hfwk_`, HENSTRUCT `hstk_`).
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
export HENSYNTH_API_KEY=hsk_…
|
|
26
|
+
# optional: export HENSYNTH_API_URL=https://hensynth.hendoi.com
|
|
27
|
+
# local: export HENSYNTH_API_URL=http://localhost:8002
|
|
28
|
+
python -c "from hensynth import Client; print(Client().usage())"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## What it cannot claim
|
|
32
|
+
|
|
33
|
+
Not full-aircraft CFD certification, not a flight-manual authority, not a substitute for OEM loads / FAR/CS compliance.
|
|
34
|
+
|
|
35
|
+
## Client methods → REST
|
|
36
|
+
|
|
37
|
+
| Method | Route notes |
|
|
38
|
+
|---|---|
|
|
39
|
+
| `usage` / `job` | `/usage` · `/jobs/:id` |
|
|
40
|
+
| `methods` | `GET /methods` |
|
|
41
|
+
| `projects` / `create_project` / `get_project` | `/projects*` |
|
|
42
|
+
| `synthesize` / `analyze` / `mission_run` | project runners |
|
|
43
|
+
| `optimize` / `sensitivity` / `trade_study` / `sweep` / `envelope` / `robust` | decide loop |
|
|
44
|
+
| `aircraft_import` / `aircraft_validate` / `aircraft_library` | aircraft ingest |
|
|
45
|
+
|
|
46
|
+
Long solves often return a job; methods with `await_job=True` (default) poll `GET /api/v1/jobs/:id`.
|
|
47
|
+
|
|
48
|
+
## Example
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from hensynth import Client
|
|
52
|
+
|
|
53
|
+
c = Client() # HENSYNTH_API_KEY
|
|
54
|
+
print(c.usage())
|
|
55
|
+
print(c.methods())
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Links
|
|
59
|
+
|
|
60
|
+
| | |
|
|
61
|
+
|---|---|
|
|
62
|
+
| **Download (PyPI)** | https://pypi.org/project/hensynth/ |
|
|
63
|
+
| Product | https://hensynth.hendoi.com |
|
|
64
|
+
| API docs | https://api.hendoi.com/?doc=hensynth-overview |
|
|
65
|
+
| Sister SDKs | `henfoil`, `hensynth`, `henmesh`, `henflow`, `henstruct` |
|
|
66
|
+
| Support | support@hendoi.com |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""HENSYNTH headless Python SDK (HS-SDK-001).
|
|
2
|
+
|
|
3
|
+
Install::
|
|
4
|
+
|
|
5
|
+
pip install hensynth
|
|
6
|
+
# or from the monorepo: pip install -e hensynth-sdk/python
|
|
7
|
+
|
|
8
|
+
Auth: copy a ``hsk_…`` key from HENSYNTH Developers after browser login.
|
|
9
|
+
Docs: https://api.hendoi.com/?doc=hensynth-overview
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from .client import Client, HensynthError
|
|
13
|
+
|
|
14
|
+
__all__ = ["Client", "HensynthError", "__version__"]
|
|
15
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"""HTTP client for HENSYNTH /api/v1 — HS-SDK-001 (0.1.0).
|
|
2
|
+
|
|
3
|
+
Auth is API-key only (``hsk_…`` from HENSYNTH Developers).
|
|
4
|
+
Each call sends ``X-Hensynth-Client: hensynth-python/<version>`` for client identification
|
|
5
|
+
(automation meters apply via ``apiRequests``; product-specific pythonSdk meters may follow).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
import time
|
|
13
|
+
import warnings
|
|
14
|
+
from typing import Any, Mapping, MutableMapping, Optional
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
import requests
|
|
18
|
+
except ImportError as exc: # pragma: no cover
|
|
19
|
+
raise ImportError("hensynth requires requests — pip install requests") from exc
|
|
20
|
+
|
|
21
|
+
CLIENT_VERSION = "0.1.0"
|
|
22
|
+
Json = MutableMapping[str, Any]
|
|
23
|
+
|
|
24
|
+
DEVELOPERS_HELP = (
|
|
25
|
+
"Create a hsk_… key: sign in at https://hendoi.com/login → open HENSYNTH → "
|
|
26
|
+
"Developers (or Settings → API) → copy the key → export HENSYNTH_API_KEY=hsk_…"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class HensynthError(RuntimeError):
|
|
31
|
+
def __init__(self, message: str, status: int = 0, body: Any = None, headers: Optional[Mapping[str, str]] = None):
|
|
32
|
+
super().__init__(message)
|
|
33
|
+
self.status = status
|
|
34
|
+
self.body = body
|
|
35
|
+
self.headers = dict(headers or {})
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def quota_exceeded(self) -> bool:
|
|
39
|
+
if not isinstance(self.body, dict):
|
|
40
|
+
return self.status == 403
|
|
41
|
+
meter = str(self.body.get("meter") or "")
|
|
42
|
+
code = str(self.body.get("code") or self.body.get("error") or "")
|
|
43
|
+
return self.status == 403 and (
|
|
44
|
+
meter in ("apiRequests", "pythonSdk") or "QUOTA" in code.upper() or "quota" in str(self).lower()
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _header_int(headers: Mapping[str, str], *names: str) -> Optional[int]:
|
|
49
|
+
for name in names:
|
|
50
|
+
for key, value in headers.items():
|
|
51
|
+
if key.lower() == name.lower() and value not in ("", "unlimited"):
|
|
52
|
+
try:
|
|
53
|
+
return int(value)
|
|
54
|
+
except ValueError:
|
|
55
|
+
return None
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _header_str(headers: Mapping[str, str], *names: str) -> Optional[str]:
|
|
60
|
+
for name in names:
|
|
61
|
+
for key, value in headers.items():
|
|
62
|
+
if key.lower() == name.lower() and value:
|
|
63
|
+
return value
|
|
64
|
+
return None
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class Client:
|
|
68
|
+
"""Headless HENSYNTH API client (pip package ``hensynth``).
|
|
69
|
+
|
|
70
|
+
Auth: pass ``api_key`` (``hsk_…``) or set ``HENSYNTH_API_KEY``.
|
|
71
|
+
Host: ``base_url`` or ``HENSYNTH_API_URL`` (default https://hensynth.hendoi.com).
|
|
72
|
+
Docs: https://api.hendoi.com/?doc=hensynth-overview
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
def __init__(
|
|
76
|
+
self,
|
|
77
|
+
api_key: Optional[str] = None,
|
|
78
|
+
base_url: Optional[str] = None,
|
|
79
|
+
timeout_s: float = 120.0,
|
|
80
|
+
poll_interval_s: float = 2.0,
|
|
81
|
+
quota_warnings: bool = True,
|
|
82
|
+
):
|
|
83
|
+
self.api_key = api_key or os.environ.get("HENSYNTH_API_KEY", "")
|
|
84
|
+
self.base_url = (base_url or os.environ.get("HENSYNTH_API_URL") or "https://hensynth.hendoi.com").rstrip("/")
|
|
85
|
+
self.timeout_s = timeout_s
|
|
86
|
+
self.poll_interval_s = poll_interval_s
|
|
87
|
+
self.quota_warnings = quota_warnings
|
|
88
|
+
self.last_quota: dict = {}
|
|
89
|
+
self._warned_keys: set = set()
|
|
90
|
+
if not self.api_key:
|
|
91
|
+
raise HensynthError(
|
|
92
|
+
"Missing API key. Set api_key= or HENSYNTH_API_KEY.\n"
|
|
93
|
+
f"{DEVELOPERS_HELP}\n"
|
|
94
|
+
"There is no `hensynth login` flow yet — keys are copied from the Developers UI."
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def _headers(self) -> dict:
|
|
98
|
+
return {
|
|
99
|
+
"Authorization": f"Bearer {self.api_key}",
|
|
100
|
+
"X-Hensynth-Key": self.api_key,
|
|
101
|
+
"X-Hensynth-Client": f"hensynth-python/{CLIENT_VERSION}",
|
|
102
|
+
"User-Agent": f"hensynth-python/{CLIENT_VERSION}",
|
|
103
|
+
"Content-Type": "application/json",
|
|
104
|
+
"Accept": "application/json",
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
def _emit_quota_warning(self, text: str, key: str) -> None:
|
|
108
|
+
if not self.quota_warnings or not text or key in self._warned_keys:
|
|
109
|
+
return
|
|
110
|
+
self._warned_keys.add(key)
|
|
111
|
+
warnings.warn(text, UserWarning, stacklevel=4)
|
|
112
|
+
print(f"hensynth: {text}", file=sys.stderr)
|
|
113
|
+
|
|
114
|
+
def _capture_quota(self, headers: Mapping[str, str]) -> dict:
|
|
115
|
+
quota = {
|
|
116
|
+
"apiLimit": _header_int(headers, "X-Hensynth-Api-Limit", "X-Api-Limit"),
|
|
117
|
+
"apiRemaining": _header_int(headers, "X-Hensynth-Api-Remaining", "X-Api-Remaining"),
|
|
118
|
+
"apiWarning": _header_str(headers, "X-Hensynth-Api-Warning", "X-Api-Warning"),
|
|
119
|
+
}
|
|
120
|
+
self.last_quota = {k: v for k, v in quota.items() if v is not None}
|
|
121
|
+
if quota.get("apiWarning"):
|
|
122
|
+
self._emit_quota_warning(str(quota["apiWarning"]), f"api:{quota.get('apiRemaining')}")
|
|
123
|
+
return self.last_quota
|
|
124
|
+
|
|
125
|
+
def _get(self, path: str, params: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None) -> Json:
|
|
126
|
+
url = f"{self.base_url}{path}"
|
|
127
|
+
r = requests.get(url, params=dict(params or {}), headers=self._headers(), timeout=timeout or self.timeout_s)
|
|
128
|
+
return self._parse(r)
|
|
129
|
+
|
|
130
|
+
def _post(self, path: str, body: Mapping[str, Any], timeout: Optional[float] = None) -> Json:
|
|
131
|
+
url = f"{self.base_url}{path}"
|
|
132
|
+
r = requests.post(url, json=dict(body), headers=self._headers(), timeout=timeout or self.timeout_s)
|
|
133
|
+
return self._parse(r)
|
|
134
|
+
|
|
135
|
+
def _parse(self, r: "requests.Response") -> Json:
|
|
136
|
+
self._capture_quota(r.headers)
|
|
137
|
+
try:
|
|
138
|
+
data = r.json() if r.content else {}
|
|
139
|
+
except Exception:
|
|
140
|
+
data = {"raw": r.text}
|
|
141
|
+
if r.status_code >= 400:
|
|
142
|
+
msg = ""
|
|
143
|
+
if isinstance(data, dict):
|
|
144
|
+
msg = str(data.get("error") or data.get("message") or data.get("detail") or "")
|
|
145
|
+
err = HensynthError(msg or f"HENSYNTH HTTP {r.status_code}", r.status_code, data, dict(r.headers))
|
|
146
|
+
if err.quota_exceeded:
|
|
147
|
+
self._emit_quota_warning(
|
|
148
|
+
"Quota exceeded. Check plan limits or wait for monthly reset. See https://hendoi.com/pricing.",
|
|
149
|
+
f"exhausted:{r.status_code}",
|
|
150
|
+
)
|
|
151
|
+
raise err
|
|
152
|
+
if not isinstance(data, dict):
|
|
153
|
+
raise HensynthError("Expected JSON object response", r.status_code, data, dict(r.headers))
|
|
154
|
+
return data
|
|
155
|
+
|
|
156
|
+
def _await_job(self, job: Json, timeout_s: float = 1800.0) -> Json:
|
|
157
|
+
job_id = job.get("jobId") or job.get("id")
|
|
158
|
+
if not job_id:
|
|
159
|
+
return job
|
|
160
|
+
deadline = time.time() + timeout_s
|
|
161
|
+
while time.time() < deadline:
|
|
162
|
+
data = self.job(str(job_id))
|
|
163
|
+
status = str(data.get("status") or data.get("state") or "").lower()
|
|
164
|
+
if status in ("done", "completed", "succeeded", "success", "completed_with_warnings"):
|
|
165
|
+
result = data.get("result") or data.get("payload") or data
|
|
166
|
+
return result if isinstance(result, dict) else {"result": result, "job": data}
|
|
167
|
+
if status in ("failed", "error", "cancelled"):
|
|
168
|
+
raise HensynthError(f"Job {job_id} {status}", 0, data)
|
|
169
|
+
time.sleep(self.poll_interval_s)
|
|
170
|
+
raise HensynthError(f"Job {job_id} timed out after {timeout_s}s", 408, job)
|
|
171
|
+
|
|
172
|
+
def _maybe_await(self, out: Json, await_job: bool) -> Json:
|
|
173
|
+
if await_job and (out.get("jobId") or out.get("status") == "queued"):
|
|
174
|
+
return self._await_job(out)
|
|
175
|
+
return out
|
|
176
|
+
|
|
177
|
+
def usage(self) -> Json:
|
|
178
|
+
return self._get("/api/v1/usage")
|
|
179
|
+
|
|
180
|
+
def job(self, job_id: str) -> Json:
|
|
181
|
+
return self._get(f"/api/v1/jobs/{job_id}")
|
|
182
|
+
|
|
183
|
+
def cancel_job(self, job_id: str) -> Json:
|
|
184
|
+
return self._post(f"/api/v1/jobs/{job_id}/cancel", {})
|
|
185
|
+
|
|
186
|
+
def methods(self) -> Json:
|
|
187
|
+
return self._get("/api/v1/methods")
|
|
188
|
+
|
|
189
|
+
def projects(self) -> Json:
|
|
190
|
+
return self._get("/api/v1/projects")
|
|
191
|
+
|
|
192
|
+
def create_project(self, body: Mapping[str, Any]) -> Json:
|
|
193
|
+
return self._post("/api/v1/projects", dict(body))
|
|
194
|
+
|
|
195
|
+
def get_project(self, project_id: str) -> Json:
|
|
196
|
+
return self._get(f"/api/v1/projects/{project_id}")
|
|
197
|
+
|
|
198
|
+
def synthesize(self, project_id: str, body: Optional[Mapping[str, Any]] = None, await_job: bool = True) -> Json:
|
|
199
|
+
out = self._post(f"/api/v1/projects/{project_id}/synthesize", dict(body or {}), timeout=max(self.timeout_s, 600.0))
|
|
200
|
+
return self._maybe_await(out, await_job)
|
|
201
|
+
|
|
202
|
+
def analyze(self, project_id: str, body: Optional[Mapping[str, Any]] = None, await_job: bool = True) -> Json:
|
|
203
|
+
out = self._post(f"/api/v1/projects/{project_id}/analyze", dict(body or {}), timeout=max(self.timeout_s, 600.0))
|
|
204
|
+
return self._maybe_await(out, await_job)
|
|
205
|
+
|
|
206
|
+
def mission_run(self, project_id: str, body: Optional[Mapping[str, Any]] = None, await_job: bool = True) -> Json:
|
|
207
|
+
out = self._post(f"/api/v1/projects/{project_id}/mission/run", dict(body or {}), timeout=max(self.timeout_s, 900.0))
|
|
208
|
+
return self._maybe_await(out, await_job)
|
|
209
|
+
|
|
210
|
+
def optimize(self, project_id: str, body: Optional[Mapping[str, Any]] = None, await_job: bool = True) -> Json:
|
|
211
|
+
out = self._post(f"/api/v1/projects/{project_id}/optimize", dict(body or {}), timeout=max(self.timeout_s, 900.0))
|
|
212
|
+
return self._maybe_await(out, await_job)
|
|
213
|
+
|
|
214
|
+
def sensitivity(self, project_id: str, body: Optional[Mapping[str, Any]] = None, await_job: bool = True) -> Json:
|
|
215
|
+
out = self._post(f"/api/v1/projects/{project_id}/sensitivity", dict(body or {}), timeout=max(self.timeout_s, 900.0))
|
|
216
|
+
return self._maybe_await(out, await_job)
|
|
217
|
+
|
|
218
|
+
def trade_study(self, project_id: str, body: Optional[Mapping[str, Any]] = None, await_job: bool = True) -> Json:
|
|
219
|
+
out = self._post(f"/api/v1/projects/{project_id}/trade-study", dict(body or {}), timeout=max(self.timeout_s, 900.0))
|
|
220
|
+
return self._maybe_await(out, await_job)
|
|
221
|
+
|
|
222
|
+
def sweep(self, project_id: str, body: Optional[Mapping[str, Any]] = None, await_job: bool = True) -> Json:
|
|
223
|
+
out = self._post(f"/api/v1/projects/{project_id}/sweep", dict(body or {}), timeout=max(self.timeout_s, 900.0))
|
|
224
|
+
return self._maybe_await(out, await_job)
|
|
225
|
+
|
|
226
|
+
def envelope(self, project_id: str, body: Optional[Mapping[str, Any]] = None, await_job: bool = True) -> Json:
|
|
227
|
+
out = self._post(f"/api/v1/projects/{project_id}/envelope", dict(body or {}), timeout=max(self.timeout_s, 900.0))
|
|
228
|
+
return self._maybe_await(out, await_job)
|
|
229
|
+
|
|
230
|
+
def robust(self, project_id: str, body: Optional[Mapping[str, Any]] = None, await_job: bool = True) -> Json:
|
|
231
|
+
out = self._post(f"/api/v1/projects/{project_id}/robust", dict(body or {}), timeout=max(self.timeout_s, 900.0))
|
|
232
|
+
return self._maybe_await(out, await_job)
|
|
233
|
+
|
|
234
|
+
def aircraft_import(self, body: Mapping[str, Any]) -> Json:
|
|
235
|
+
return self._post("/api/v1/aircraft/import", dict(body))
|
|
236
|
+
|
|
237
|
+
def aircraft_validate(self, body: Mapping[str, Any]) -> Json:
|
|
238
|
+
return self._post("/api/v1/aircraft/validate", dict(body))
|
|
239
|
+
|
|
240
|
+
def aircraft_library(self) -> Json:
|
|
241
|
+
return self._get("/api/v1/aircraft-library")
|
|
242
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hensynth
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official HENSYNTH Python SDK (HS-SDK-001) — aircraft / mission synthesis: projects, synthesize, analyze, mission, optimize, trade-study.
|
|
5
|
+
Author-email: HENDOI TECHNOLOGIES PRIVATE LIMITED <support@hendoi.com>
|
|
6
|
+
License-Expression: LicenseRef-Proprietary
|
|
7
|
+
Project-URL: Homepage, https://hensynth.hendoi.com
|
|
8
|
+
Project-URL: Documentation, https://api.hendoi.com/?doc=hensynth-overview
|
|
9
|
+
Project-URL: Product, https://hendoi.com/products/hensynth
|
|
10
|
+
Project-URL: Issues, https://hendoi.com/contact
|
|
11
|
+
Project-URL: PyPI, https://pypi.org/project/hensynth/
|
|
12
|
+
Keywords: hensynth,aerospace,MDO,HENDOI,SDK
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: requests>=2.28
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
27
|
+
Requires-Dist: build; extra == "dev"
|
|
28
|
+
Requires-Dist: twine; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# hensynth — Python SDK (HS-SDK-001)
|
|
32
|
+
|
|
33
|
+
Official headless HTTPS client for production [HENSYNTH](https://hensynth.hendoi.com). Same REST surface as the workspace.
|
|
34
|
+
|
|
35
|
+
**Version 0.1.0** · **Docs:** [https://api.hendoi.com/?doc=hensynth-overview](https://api.hendoi.com/?doc=hensynth-overview) · **Download:** [pypi.org/project/hensynth](https://pypi.org/project/hensynth/)
|
|
36
|
+
|
|
37
|
+
Header on every call: `X-Hensynth-Client: hensynth-python/0.1.0`.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install hensynth
|
|
43
|
+
# monorepo:
|
|
44
|
+
pip install -e hensynth-sdk/python
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Requires Python ≥ 3.9. License: **LicenseRef-Proprietary** (HENDOI).
|
|
48
|
+
|
|
49
|
+
## Auth
|
|
50
|
+
|
|
51
|
+
Create a `hsk_…` key on HENSYNTH → **Developers**. Keys do not cross products
|
|
52
|
+
(HENFOIL `hfk_`, HENSYNTH `hsk_`, HENMESH `hmk_`, HENFLOW `hfwk_`, HENSTRUCT `hstk_`).
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
export HENSYNTH_API_KEY=hsk_…
|
|
56
|
+
# optional: export HENSYNTH_API_URL=https://hensynth.hendoi.com
|
|
57
|
+
# local: export HENSYNTH_API_URL=http://localhost:8002
|
|
58
|
+
python -c "from hensynth import Client; print(Client().usage())"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## What it cannot claim
|
|
62
|
+
|
|
63
|
+
Not full-aircraft CFD certification, not a flight-manual authority, not a substitute for OEM loads / FAR/CS compliance.
|
|
64
|
+
|
|
65
|
+
## Client methods → REST
|
|
66
|
+
|
|
67
|
+
| Method | Route notes |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `usage` / `job` | `/usage` · `/jobs/:id` |
|
|
70
|
+
| `methods` | `GET /methods` |
|
|
71
|
+
| `projects` / `create_project` / `get_project` | `/projects*` |
|
|
72
|
+
| `synthesize` / `analyze` / `mission_run` | project runners |
|
|
73
|
+
| `optimize` / `sensitivity` / `trade_study` / `sweep` / `envelope` / `robust` | decide loop |
|
|
74
|
+
| `aircraft_import` / `aircraft_validate` / `aircraft_library` | aircraft ingest |
|
|
75
|
+
|
|
76
|
+
Long solves often return a job; methods with `await_job=True` (default) poll `GET /api/v1/jobs/:id`.
|
|
77
|
+
|
|
78
|
+
## Example
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from hensynth import Client
|
|
82
|
+
|
|
83
|
+
c = Client() # HENSYNTH_API_KEY
|
|
84
|
+
print(c.usage())
|
|
85
|
+
print(c.methods())
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Links
|
|
89
|
+
|
|
90
|
+
| | |
|
|
91
|
+
|---|---|
|
|
92
|
+
| **Download (PyPI)** | https://pypi.org/project/hensynth/ |
|
|
93
|
+
| Product | https://hensynth.hendoi.com |
|
|
94
|
+
| API docs | https://api.hendoi.com/?doc=hensynth-overview |
|
|
95
|
+
| Sister SDKs | `henfoil`, `hensynth`, `henmesh`, `henflow`, `henstruct` |
|
|
96
|
+
| Support | support@hendoi.com |
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
hensynth/__init__.py
|
|
5
|
+
hensynth/client.py
|
|
6
|
+
hensynth.egg-info/PKG-INFO
|
|
7
|
+
hensynth.egg-info/SOURCES.txt
|
|
8
|
+
hensynth.egg-info/dependency_links.txt
|
|
9
|
+
hensynth.egg-info/requires.txt
|
|
10
|
+
hensynth.egg-info/top_level.txt
|
|
11
|
+
tests/test_client_basic.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
hensynth
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0.3", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hensynth"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official HENSYNTH Python SDK (HS-SDK-001) — aircraft / mission synthesis: projects, synthesize, analyze, mission, optimize, trade-study."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "LicenseRef-Proprietary"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "HENDOI TECHNOLOGIES PRIVATE LIMITED", email = "support@hendoi.com" }]
|
|
14
|
+
keywords = ["hensynth", "aerospace", "MDO", "HENDOI", "SDK"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Scientific/Engineering",
|
|
24
|
+
]
|
|
25
|
+
dependencies = ["requests>=2.28"]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
dev = ["pytest>=7", "build", "twine"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://hensynth.hendoi.com"
|
|
32
|
+
Documentation = "https://api.hendoi.com/?doc=hensynth-overview"
|
|
33
|
+
Product = "https://hendoi.com/products/hensynth"
|
|
34
|
+
Issues = "https://hendoi.com/contact"
|
|
35
|
+
PyPI = "https://pypi.org/project/hensynth/"
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.packages.find]
|
|
38
|
+
where = ["."]
|
|
39
|
+
include = ["hensynth*"]
|
hensynth-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Unit tests for hensynth Client (no live network)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from hensynth import Client, HensynthError, __version__
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_version():
|
|
11
|
+
assert __version__ == "0.1.0"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_missing_key():
|
|
15
|
+
with pytest.raises(HensynthError) as ei:
|
|
16
|
+
Client(api_key="")
|
|
17
|
+
assert "HENSYNTH_API_KEY" in str(ei.value)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_headers():
|
|
21
|
+
c = Client(api_key="hsk_test", base_url="https://hensynth.hendoi.com")
|
|
22
|
+
h = c._headers()
|
|
23
|
+
assert h["Authorization"].startswith("Bearer hsk_")
|
|
24
|
+
assert h["X-Hensynth-Key"] == "hsk_test"
|
|
25
|
+
assert "hensynth-python/" in h["X-Hensynth-Client"]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_quota_exceeded_flag():
|
|
29
|
+
e = HensynthError("limit", 403, {"meter": "apiRequests", "code": "QUOTA_EXCEEDED"})
|
|
30
|
+
assert e.quota_exceeded is True
|