Repository navigation
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
…wo relatively clean approaches to choose from.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
============================================
- Coverage 100.00% 26.92% -73.08%
============================================
Files 2 5 +3
Lines 7 182 +175
============================================
+ Hits 7 49 +42
- Misses 0 133 +133 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…naries of values. Here we expect a model that returns a dict to have keys that match the columns in PRED_META.
There was a problem hiding this comment.
🟡 Changes recommended
Nested-input handling, CPU initialization, and shared or stale dataset state can prevent inference or produce incorrect predictions.
4 open issues
What changed in this PR
This PR moves Hyrax inference boilerplate from a proof-of-concept notebook into reusable LSDB integration APIs, supporting both managed clients and existing Dask clients.
Changes:
- Adds
ml_client, worker-plugin registration, and partition-level prediction. - Introduces a dataframe dataset adapter with nested-field getters and padded batching.
- Adds usage notebooks and example model assets, updates dependencies, and removes template tests.
| File | Description |
|---|---|
tests/lsdb_ml/test_example_module.py |
Removes template example tests. |
src/lsdb_ml/hyrax/worker_plugin.py |
Adds model loading, plugin registration, and partition inference. |
src/lsdb_ml/hyrax/datasets/hyrax_dataframe_dataset.py |
Adapts dataframe fields and nested arrays for Hyrax. |
src/lsdb_ml/hyrax/client.py |
Adds managed Dask client creation and cleanup. |
src/lsdb_ml/__init__.py |
Exports ml_client and predict. |
pyproject.toml |
Makes LSDB and Hyrax required dependencies. |
docs/pre_executed/original_lsdb_style_api_infer.ipynb |
Preserves the original inference prototype. |
docs/pre_executed/loopback_weights/prepare_inputs.py |
Supplies input preparation for the loopback example. |
docs/pre_executed/loopback_weights/fake_weights.pth |
Adds an example weights asset. |
docs/pre_executed/goal_lsdb_style_api_infer.ipynb |
Demonstrates managed and explicit plugin-registration workflows. |
Review effort: Balanced
|
|
||
| for col in nested_cols: | ||
| meta_dict[col] = {} | ||
| for ncols in nested_frame[col].columns: |
| data_request = {"infer": {"data": data}} | ||
| self.config["data_request"] = data_request | ||
|
|
||
| if not self.dataset_prepped: | ||
| datasets = setup_dataset(self.config, shuffle=False) | ||
| self.dataset = datasets["infer"] | ||
| self.dataset_prepped = True |
| # for inference. | ||
| # NOTE: `dataset` is a Hyrax DataProvider passed to `dist_data_loader`, | ||
| # not the bare dataset class. | ||
| dataset.prepped_datasets["data"].data = df |
| device = torch.accelerator.current_accelerator() | ||
| self.process_fn = create_process_func("infer_batch", device.type, self.model, self.config) |


The goal of the PR is to start with the POC notebook that showed use of a WorkerPlugin to create a model instance on each dask worker for running inference and abstract away as much of the boilerplate code as possible.
The notebook
goal_lsdb_style_api_infer.ipynbrepresents (what I think is) the best case API.From that notebook there are two example paths shows:
ml_clientcreate and add the Hyrax WorkerPlugin to the clients. Then the user callscatalog.map_partitions(predict, ...).map_partitions(predict, ...)call - register the WorkerPlugin with clients that are already instantiate, then call.map_partitions(predict, ...). This approach might allow for easier subsequent UDFs to be run after data has been processed through the model.