-
Notifications
You must be signed in to change notification settings - Fork 11
[DE-7859] Expose pHash on DatasetItem (v0.18.3) #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vinay553
wants to merge
3
commits into
master
Choose a base branch
from
vinayparakala/expose-phash-on-dataset-item
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # CLAUDE.md | ||
|
|
||
| Notes for Claude Code when working in this repo (the Nucleus Python SDK). | ||
|
|
||
| ## What this repo is | ||
|
|
||
| The official Python client for Nucleus. Wraps the `/v1/nucleus` REST endpoints on `scaleapi`. Distributed on PyPI as `scale-nucleus`. | ||
|
|
||
| - Sources live under `nucleus/`. | ||
| - Backend lives in the `scaleapi` repo at `server/src/routes/v1/select.ts` and `server/src/lib/select/api/`. | ||
| - The default API base URL is `NUCLEUS_ENDPOINT = "https://api.scale.com/v1/nucleus"` (`nucleus/constants.py`). Override via the `endpoint=` kwarg or `NUCLEUS_ENDPOINT` env var (e.g. point at fedramp). | ||
|
|
||
| ## Release workflow | ||
|
|
||
| Releases are version-numbered with [Semantic Versioning](https://semver.org/) and tracked in `CHANGELOG.md` using the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. | ||
|
|
||
| When making a user-facing change, the convention (see PRs #459, #455) is: | ||
|
|
||
| 1. Bump `version = "..."` in `pyproject.toml` under `[tool.poetry]`. This is the single version source — there is no `__version__` in `nucleus/__init__.py`. | ||
| - Patch bump for additive, backwards-compatible changes (new fields, new methods). | ||
| - Minor bump for new features that change behaviour or remove deprecated paths. | ||
| - Major bump for breaking changes (Python version drops, sentinel removal, etc.). | ||
| 2. Prepend a `## [X.Y.Z](https://github.com/scaleapi/nucleus-python-client/releases/tag/vX.Y.Z) - YYYY-MM-DD` section to `CHANGELOG.md` with `### Added` / `### Changed` / `### Fixed` / `### Removed` subsections as appropriate. | ||
| 3. Commit the version bump + CHANGELOG entry alongside the code change in the same PR. | ||
|
|
||
| Pure refactors / doc-only PRs (#456) sometimes skip the version bump. When in doubt, bump. | ||
|
|
||
| ## Branch and PR conventions | ||
|
|
||
| - Branch naming: `<author>/<kebab-description>` (e.g. `vinayparakala/expose-phash-on-dataset-item`). | ||
| - PR title commonly starts with the Linear ticket: `[DE-XXXX] <description>` — see `git log --oneline -20`. | ||
| - PRs land via squash merge. | ||
|
|
||
| ## Architecture pointers | ||
|
|
||
| - `nucleus/__init__.py` — `NucleusClient`, top-level operations. | ||
| - `nucleus/dataset.py` — `Dataset` class. Most user-facing methods live here (item upload/fetch, generators, queries, slices, autotags, exports). Generators page through the backend via `nucleus/utils.py:paginate_generator`. | ||
| - `nucleus/dataset_item.py` — `DatasetItem` dataclass. **`DatasetItem.from_json` is the single deserialization entry point** for items coming back from the API — every SDK method that returns a `DatasetItem` (generators, queries, `iloc`/`refloc`/`loc`, the `items` property) routes through it. To expose a new server-side field on items, add it to the dataclass + `from_json` and you're done on the SDK side. | ||
| - `nucleus/utils.py` — `convert_export_payload` and `format_dataset_item_response` are the shared shapers used by the export and single-item endpoints. They wrap raw JSON into typed objects via the respective `from_json` classmethods. | ||
| - `nucleus/constants.py` — All API payload keys are constants here. When adding a new field, add a `*_KEY` constant first and reference it from `from_json` / `to_payload` rather than inlining the string. | ||
| - `nucleus/annotation.py`, `nucleus/prediction.py` — Annotation and prediction types. Each has its own `from_json` / `to_payload`. | ||
|
|
||
| ## Testing | ||
|
|
||
| Run the suite from the repo root: | ||
|
|
||
| ```bash | ||
| poetry install | ||
| poetry run pytest tests | ||
| ``` | ||
|
|
||
| Many tests require a real `NUCLEUS_API_KEY` and hit the live API; use `pytest -k <name>` to scope. Pre-commit hooks (`.pre-commit-config.yaml`) run black, ruff, isort. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix flaky test.