| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| def deduplicate( | ||
| self, | ||
| threshold: int, | ||
| reference_ids: Optional[List[str]] = None, |
There was a problem hiding this comment.
Can you make it clearer in the docstring what the difference is between this and the following endpoint?
Sorry, something went wrong.
There was a problem hiding this comment.
Good call, will do
Sorry, something went wrong.
| ) | ||
|
|
||
|
|
||
| def test_job_listing_and_retrieval(CLIENT): |
There was a problem hiding this comment.
Fixing this flaky test by splitting listing and retrieval into 2 and making the test deterministic
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
See title.
Merge in after sister pr is deployed: https://github.com/scaleapi/scaleapi/pull/134861
Added some unit and integration tests. Some of these tests create an image fixture dataset and a video fixture dataset. Both are made up of TEST_IMAGE_URLS so...
To get the integrations tests to completely pass, I had to run some backfills. Specifically I had to backfill each TEST_IMAGE_URL from TEST_IMAGE_URLS
Backfill all occurrences of all (TEST_IMAGE_URL, 60ad648c85db770026e9bf77) in nucleus.processing_upload table
Backfill all occurrences of TEST_IMAGE_URL in nucleus.processed_upload table
See this comment for more info
Example test script of valid usage:
import nucleus # define variables corp_api_key="<SCALE_API_KEY>" customer_id="68921622befbf26f9e535024" SCALE_API_KEY=f"{corp_api_key}|{customer_id}" endpoint="http://localhost:3000/v1/nucleus" dataset_id = "ds_d6ccka5zks5g0bheab8g" # initialize client client = nucleus.NucleusClient(SCALE_API_KEY, endpoint=endpoint) print(client) dataset = client.get_dataset(dataset_id) print(dataset) entire_dataset_dedup = dataset.deduplicate(threshold=30) print(entire_dataset_dedup) print() ref_ids_dedup = dataset.deduplicate(threshold=10, reference_ids=["video1/0", "video1/1", "video1/2", "video1/3", "video1/4", "video1/5"]) print(ref_ids_dedup) print(ref_ids_dedup.stats) print() dataset_item_ids_dedup = dataset.deduplicate_by_ids(threshold=10, dataset_item_ids=["di_d6ccmm2mc93g23g1maag", "di_d6ccmm2mc93g23g1mab0", "di_d6ccmm2mc93g23g1mabg", "di_d6ccmm2mc93g23g1mac0", "di_d6ccmm2mc93g23g1macg", "di_d6ccmm2mc93g23g1mad0"]) print(ref_ids_dedup) print(ref_ids_dedup.stats)Output:
Examples of invalid usage:
# not passing threshold entire_dataset_dedup = dataset.deduplicate() # output entire_dataset_dedup = dataset.deduplicate() ^^^^^^^^^^^^^^^^^^^^^ TypeError: Dataset.deduplicate() missing 1 required positional argument: 'threshold'# invalid threshold entire_dataset_dedup = dataset.deduplicate(threshold=70) # or entire_dataset_dedup = dataset.deduplicate(threshold=-5) # output (for both) Tried to post http://localhost:3000/v1/nucleus/dataset/ds_d6ccka5zks5g0bheab8g/deduplicate, but received 400: Bad Request. The detailed error is: {"error":"An unexpected internal error occured: threshold must be an integer between 0 and 64","route":"/v1/nucleus/dataset/ds_d6ccka5zks5g0bheab8g/deduplicate","request_id":"51bb8a48-0a63-44f8-8ef5-5954493b0edb","status_code":400}Greptile Summary
This PR adds image deduplication support to the Nucleus Python SDK via perceptual hashing (pHash). Two new methods are added to the Dataset class: deduplicate() for deduplication by reference IDs (or entire dataset), and deduplicate_by_ids() for deduplication by internal dataset item IDs. Results are returned as structured DeduplicationResult and DeduplicationStats dataclasses.
Confidence Score: 5/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant User participant Dataset participant NucleusClient participant API as Nucleus API User->>Dataset: deduplicate(threshold, reference_ids?) Dataset->>Dataset: Validate reference_ids not empty list Dataset->>NucleusClient: make_request(payload, "dataset/{id}/deduplicate") NucleusClient->>API: POST /dataset/{id}/deduplicate API-->>NucleusClient: {unique_item_ids, unique_reference_ids, stats} NucleusClient-->>Dataset: response dict Dataset-->>User: DeduplicationResult User->>Dataset: deduplicate_by_ids(threshold, dataset_item_ids) Dataset->>Dataset: Validate dataset_item_ids not empty Dataset->>NucleusClient: make_request(payload, "dataset/{id}/deduplicate") NucleusClient->>API: POST /dataset/{id}/deduplicate API-->>NucleusClient: {unique_item_ids, unique_reference_ids, stats} NucleusClient-->>Dataset: response dict Dataset-->>User: DeduplicationResultLast reviewed commit: 4cfc129