Skip to content

Encapsulating Hyrax - #10

Open
drewoldag wants to merge 5 commits into
mainfrom
awo/hyrax-encapsulation
Open

drewoldag wants to merge 5 commits into
mainfrom
awo/hyrax-encapsulation

Conversation

@drewoldag

@drewoldag drewoldag commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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.ipynb represents (what I think is) the best case API.

From that notebook there are two example paths shows:

  1. Context manager instantiation - let a context manager called ml_client create and add the Hyrax WorkerPlugin to the clients. Then the user calls catalog.map_partitions(predict, ...)
  2. Bare .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.

@drewoldag drewoldag self-assigned this Oct 20, 2026
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 24.85876% with 133 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.92%. Comparing base (c9ed114) to head (4b9d522).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
.../lsdb_ml/hyrax/datasets/hyrax_dataframe_dataset.py 20.00% 68 Missing ⚠️
src/lsdb_ml/hyrax/worker_plugin.py 25.00% 57 Missing ⚠️
src/lsdb_ml/hyrax/client.py 38.46% 8 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…naries of values. Here we expect a model that returns a dict to have keys that match the columns in PRED_META.
@drewoldag drewoldag changed the title WIP - Encapsulating Hyrax Encapsulating Hyrax Oct 23, 2026
@drewoldag
drewoldag marked this pull request as ready for review October 23, 2026 22:54
@drewoldag
drewoldag requested review from dougbrn and a balanced review from Copilot October 23, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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:
Comment on lines +71 to +77
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
Comment on lines +50 to +51
device = torch.accelerator.current_accelerator()
self.process_fn = create_process_func("infer_batch", device.type, self.model, self.config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants