Skip to content

Commit 93cb518

Browse files
authored
Enforce mutually exclusive api_key and limited_access_key inputs in NucleusClient and fix all remaining Sphinx doc build warnings (#457)
* Make different auth keys mutually exclusive * Fix mypy errors * Re-add UploadResponse export from init file * Undo removal of unused imports
1 parent 400dfd8 commit 93cb518

File tree

8 files changed

+149
-177
lines changed

8 files changed

+149
-177
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to the [Nucleus Python Client](https://github.com/scaleapi/n
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.17.14](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.17.14) - 2026-04-14
9+
10+
### Changed
11+
- `api_key` and `limited_access_key` are now mutually exclusive in `NucleusClient`. Passing both (or setting `NUCLEUS_API_KEY` while also passing `limited_access_key`) raises a `ValueError`.
12+
13+
### Fixed
14+
- Docstring improvements across `NucleusClient`: fixed copy-paste errors (`get_job`, `get_slice`, `delete_slice`), removed phantom `stats_only` parameter from `list_jobs`, corrected `make_request` parameter name, and restructured `create_launch_model`/`create_launch_model_from_dir` docs for proper rendering.
15+
- Suppressed Sphinx warnings from inherited pydantic `BaseModel` methods by removing `inherited-members` from autoapi options.
16+
817
## [0.17.13](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.17.13) - 2026-03-06
918

1019
### Fixed

cli/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ def init_client():
1313

1414
api_key = os.environ.get("NUCLEUS_API_KEY", None)
1515
limited_access_key = os.environ.get("NUCLEUS_LIMITED_ACCESS_KEY", None)
16+
if api_key and limited_access_key:
17+
raise RuntimeError(
18+
"Both NUCLEUS_API_KEY and NUCLEUS_LIMITED_ACCESS_KEY are set. "
19+
"Please set only one."
20+
)
1621
if api_key or limited_access_key:
1722
client = nucleus.NucleusClient(api_key=api_key, limited_access_key=limited_access_key)
1823
else:

conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
@pytest.fixture(scope="session")
2424
def CLIENT():
2525
if API_KEY and LIMITED_ACCESS_KEY:
26-
return nucleus.NucleusClient(api_key=API_KEY, limited_access_key=LIMITED_ACCESS_KEY)
26+
raise RuntimeError(
27+
"Set only one of NUCLEUS_PYTEST_API_KEY or NUCLEUS_PYTEST_LIMITED_ACCESS_KEY, not both."
28+
)
2729
if API_KEY:
2830
return nucleus.NucleusClient(api_key=API_KEY)
2931
# LIMITED_ACCESS_KEY only

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
# directories to ignore when looking for source files.
4949
# This pattern also affects html_static_path and html_extra_path.
5050
exclude_patterns = []
51+
suppress_warnings = ["toc.not_included"]
5152

5253

5354
# -- Options for HTML output -------------------------------------------------
@@ -75,7 +76,6 @@
7576
autoapi_options = [
7677
"members",
7778
"no-undoc-members",
78-
"inherited-members",
7979
"show-module-summary",
8080
"imported-members",
8181
]

nucleus/__init__.py

Lines changed: 120 additions & 174 deletions
Large diffs are not rendered by default.

nucleus/connection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ def __init__(self, api_key: Optional[str] = None, endpoint: Optional[str] = None
1717
self.api_key = api_key
1818
self.endpoint = endpoint
1919
self.extra_headers = extra_headers or {}
20+
if self.api_key is not None and self.extra_headers.get(
21+
"x-limited-access-key"
22+
):
23+
raise ValueError(
24+
"Cannot use both api key and limited access key simultaneously."
25+
)
2026
# Require at least one auth mechanism: Basic (api_key) or limited access header
2127
if self.api_key is None and not self.extra_headers.get("x-limited-access-key"):
2228
raise NoAPIKey()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ignore = ["E501", "E741", "E731", "F401"] # Easy ignore for getting it running
2525

2626
[tool.poetry]
2727
name = "scale-nucleus"
28-
version = "0.17.13"
28+
version = "0.17.14"
2929
description = "The official Python client library for Nucleus, the Data Platform for AI"
3030
license = "MIT"
3131
authors = ["Scale AI Nucleus Team <nucleusapi@scaleapi.com>"]

scripts/load_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ def client():
8585
raise RuntimeError(
8686
"Set at least one of api_key or limited_access_key (via flags or env)."
8787
)
88+
if FLAGS.api_key and FLAGS.limited_access_key:
89+
raise RuntimeError(
90+
"Set only one of api_key or limited_access_key (via flags or env), not both."
91+
)
8892
return nucleus.NucleusClient(
8993
api_key=FLAGS.api_key, limited_access_key=FLAGS.limited_access_key
9094
)

0 commit comments

Comments
 (0)