Skip to content

refactor: Move code to appropriate folders for CODEOWNERS#199

Open
yuechao-qin wants to merge 1 commit intomasterfrom
ycq/refactor-folders-codeowners
Open

refactor: Move code to appropriate folders for CODEOWNERS#199
yuechao-qin wants to merge 1 commit intomasterfrom
ycq/refactor-folders-codeowners

Conversation

@yuechao-qin
Copy link
Copy Markdown
Collaborator

@yuechao-qin yuechao-qin commented Apr 3, 2026

Overview

Closes https://github.com/Shopify/oasis-frontend/issues/525

Reorganized cloud_pipelines_backend/ by extracting search, annotation, execution, and backfill logic from the monolithic api_server_sql.py into dedicated subpackages (i.e. folders). Tests were split and relocated to mirror the new source structure. No behavioral changes.

New Directories

Directory Purpose
cloud_pipelines_backend/search/ Filter query models, SQL generation, and pipeline run list/pagination logic
cloud_pipelines_backend/annotation/ System annotation mirroring, validation guards, and truncation helpers
cloud_pipelines_backend/execution/ ExecutionStatusSummary dataclass
cloud_pipelines_backend/backfill/ Annotation backfill migrations (renamed from database_migrations.py)

Why make this change?

The new dedicated folders can be applied to the appropriate CODEOWNERS.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@yuechao-qin yuechao-qin marked this pull request as ready for review April 3, 2026 23:14
@yuechao-qin yuechao-qin requested a review from Ark-kun as a code owner April 3, 2026 23:14
@yuechao-qin yuechao-qin force-pushed the ycq/refactor-folders-codeowners branch from 549f6b8 to 628450d Compare April 4, 2026 00:14
@yuechao-qin yuechao-qin force-pushed the ycq/refactor-folders-codeowners branch from 628450d to cef2844 Compare April 4, 2026 00:16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's leave it in api_server. Too small.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's keep it where it was.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's move this to search/pipeline_run_annotations.py

Copy link
Copy Markdown
Contributor

@Ark-kun Ark-kun Apr 17, 2026

Choose a reason for hiding this comment

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

General style:
All module names should be either plural or uncountable nouns (to avoid clashes with local variables). "search" seems kind of fine. Although if we were a search system dealing with many searches, it would not hav been fine.
Generic catch-all module names like "utils" should be avoided as they tend to accumulate unrelated functionality.

class ListPipelineJobsResponse:
pipeline_runs: list[PipelineRunResponse]
next_page_token: str | None = None

Copy link
Copy Markdown
Contributor

@Ark-kun Ark-kun Apr 17, 2026

Choose a reason for hiding this comment

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

I think that such "response" classes belong to api_server_sql.
I suggest returning pipeline_runs + next page token

Comment on lines -231 to -258

return ListPipelineJobsResponse(
pipeline_runs=[
self._create_pipeline_run_response(
session=session,
pipeline_run=pipeline_run,
include_pipeline_names=include_pipeline_names,
include_execution_stats=include_execution_stats,
)
for pipeline_run in pipeline_runs
],
next_page_token=next_page_token,
)

def _create_pipeline_run_response(
self,
*,
session: orm.Session,
pipeline_run: bts.PipelineRun,
include_pipeline_names: bool,
include_execution_stats: bool,
) -> PipelineRunResponse:
response = PipelineRunResponse.from_db(pipeline_run)
if include_pipeline_names:
pipeline_name = None
extra_data = pipeline_run.extra_data or {}
if self._PIPELINE_NAME_EXTRA_DATA_KEY in extra_data:
pipeline_name = extra_data[self._PIPELINE_NAME_EXTRA_DATA_KEY]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's keep this code in this module.
The basic functionality unrelated to search should remain here.

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