You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Commit message format:** All commits must include a Jira ticket ID, e.g. `SDK-123: description`. CI enforces this on PRs.
39
+
40
+
## Architecture
41
+
42
+
### Entry point and builder
43
+
44
+
`skyflow/client/skyflow.py` — `Skyflow` is a facade built via `Skyflow.builder()`. The inner `Builder` class accumulates vault configs, connection configs, and optional Skyflow-level credentials. Calling `.build()` validates all configs and instantiates `VaultClient` + controller objects per config. Each `add_vault_config()` call creates a `Vault` controller and a `Detect` controller backed by the same `VaultClient`.
-`skyflow/vault/controller/_connections.py` — `Connection`: single `invoke()` method that builds an HTTP request via `requests.PreparedRequest` and sends it directly (bypasses the generated client).
50
+
-`skyflow/vault/controller/_detect.py` — `Detect`: deidentify/reidentify text and files. File operations use long-polling (`__poll_for_processed_file`) with exponential back-off up to a configurable `wait_time` (max 64 s).
51
+
52
+
### VaultClient (auth and token caching)
53
+
54
+
`skyflow/vault/client/client.py` — Holds the generated REST client (`skyflow/generated/rest/`) and manages bearer token lifecycle. `initialize_client_configuration()` is called before every API request; it skips re-initialization if a non-expired token exists. Credential resolution order: config-level credentials → Skyflow-level credentials → `SKYFLOW_CREDENTIALS` env var.
55
+
56
+
### Service account / JWT layer
57
+
58
+
`skyflow/service_account/_utils.py` — Standalone functions for bearer token generation (`generate_bearer_token`, `generate_bearer_token_from_creds`) and signed data tokens (`generate_signed_data_tokens`). Signs a JWT with RS256 then exchanges it at the `tokenURI` via `AuthClient`. `is_expired()` decodes JWT without verification to check `exp`.
59
+
60
+
### Generated REST client
61
+
62
+
`skyflow/generated/rest/` — **Do not edit.** Auto-generated by Fern from the Skyflow API spec. All vault/token/query/detect/file API calls go through this layer. The `Skyflow` class in `generated/rest/client.py` is the raw HTTP client (separate from `skyflow/client/skyflow.py`).
63
+
64
+
### Validation
65
+
66
+
`skyflow/utils/validations/_validations.py` — All request and config validation lives here. Every public SDK method calls a corresponding `validate_*` function before touching the API. Config-level validation (vault, connection, credentials) runs at `build()` / `add_*_config()` time.
67
+
68
+
### Error handling
69
+
70
+
`skyflow/error/_skyflow_error.py` — `SkyflowError(message, http_code, request_id, grpc_code, http_status, details)`. `handle_exception()` in `skyflow/utils/_utils.py` converts raw generated-client exceptions into `SkyflowError` by inspecting `content-type` of the error response.
71
+
72
+
### Messages and constants
73
+
74
+
-`skyflow/utils/_skyflow_messages.py` — All user-facing error strings, log strings, and HTTP status enums. Strings are grouped into `Error`, `ErrorLogs`, `Info`, `ErrorCodes`, `HttpStatus` inner enums.
75
+
-`skyflow/utils/constants.py` — Named constant classes (`CredentialField`, `JWT`, `SdkMetricsKey`, etc.) and top-level constants (`PROTOCOL`, `SKY_META_DATA_HEADER`).
76
+
-`skyflow/utils/enums/` — `LogLevel`, `Env`, `RedactionType`, `TokenMode`, `ContentType`, `DetectEntities`, etc.
77
+
78
+
### Request/Response objects
79
+
80
+
Plain dataclasses in `skyflow/vault/data/`, `skyflow/vault/tokens/`, `skyflow/vault/detect/`, and `skyflow/vault/connection/`. Response objects always have an `errors` field (list or `None`).
81
+
82
+
### SDK metadata header
83
+
84
+
Every API call appends `sky-metadata: <json>` via `__get_headers()`. The metrics dict (`skyflow/utils/_utils.py:get_metrics()`) is computed once per process and cached in `_CACHED_METRICS`.
0 commit comments