-
Notifications
You must be signed in to change notification settings - Fork 6
refactor(admin-api): generalize scheduler trait over job kinds #1842
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| use std::fmt::Debug; | ||
|
|
||
| use amp_datasets_registry::error::{ListVersionTagsError, ResolveRevisionError}; | ||
| use amp_worker_datasets_derived::job_descriptor::JobDescriptor as MaterializeDerivedDatasetJobDescriptor; | ||
| use amp_worker_datasets_raw::job_descriptor::JobDescriptor as MaterializeRawDatasetJobDescriptor; | ||
| use axum::{ | ||
| Json, | ||
| extract::{ | ||
|
|
@@ -11,6 +13,7 @@ use axum::{ | |
| }; | ||
| use common::dataset_store::GetDatasetError; | ||
| use datasets_common::{name::Name, namespace::Namespace, reference::Reference, revision::Revision}; | ||
| use datasets_derived::DerivedDatasetKind; | ||
| use monitoring::logging; | ||
| use worker::job::JobId; | ||
|
|
||
|
|
@@ -143,16 +146,30 @@ pub async fn handler( | |
| .await | ||
| .map_err(Error::GetDataset)?; | ||
|
|
||
| // Build the job descriptor based on dataset kind | ||
| let job_descriptor = if dataset.kind() == DerivedDatasetKind { | ||
| MaterializeDerivedDatasetJobDescriptor { | ||
| end_block: end_block.into(), | ||
| dataset_namespace: reference.namespace().clone(), | ||
| dataset_name: reference.name().clone(), | ||
| manifest_hash: reference.hash().clone(), | ||
| } | ||
| .into() | ||
| } else { | ||
| MaterializeRawDatasetJobDescriptor { | ||
| end_block: end_block.into(), | ||
| max_writers: parallelism, | ||
| dataset_namespace: reference.namespace().clone(), | ||
| dataset_name: reference.name().clone(), | ||
| manifest_hash: reference.hash().clone(), | ||
| } | ||
| .into() | ||
| }; | ||
|
Comment on lines
+150
to
+167
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this logic to a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping this in the handler intentionally.
Eventually, these will be extracted directly from the request body, so the handler is the right place for this logic. |
||
|
|
||
| // Schedule the extraction job using the scheduler | ||
| let job_id = ctx | ||
| .scheduler | ||
| .schedule_dataset_sync_job( | ||
| reference.clone(), | ||
| dataset.kind().clone(), | ||
| end_block.into(), | ||
| parallelism, | ||
| worker_id, | ||
| ) | ||
| .schedule_job(reference.clone(), job_descriptor, worker_id) | ||
| .await | ||
| .map_err(|err| { | ||
| tracing::error!( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.