Skip to content

feat: start background jobs by name with JSON input - #3746

Open
iunir wants to merge 2 commits into
mainfrom
iunir-lig-11460-6-submit-by-name
Open

iunir wants to merge 2 commits into
mainfrom
iunir-lig-11460-6-submit-by-name

Conversation

@iunir

@iunir iunir commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What has changed and why?

  • JobRunner.submit now takes a job name and JSON input, not a Python function.
  • The runner checks the input at submit. An unknown job name or input that is not JSON fails at once, and no job is created.
  • The job gets a copy of the input, as it would in another process.

How has it been tested?

  • Changed the runner, route and client tests to start jobs by name.
  • Added tests for an unknown job name, input that is not JSON, and a change to the input after submit.

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • New Features
    • Jobs can now be submitted by registered name with a JSON-compatible input payload, which is provided to the job when it runs.
  • Bug Fixes
    • Submissions with unknown job names or inputs that cannot be represented as JSON are rejected before the job runs.
    • Submitted inputs are copied before execution, preventing later changes to the original payload from affecting the job.

@iunir iunir self-assigned this Dec 4, 2026
@iunir
iunir added this pull request to stack #3747 December 4, 2026 08:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T08:42:27.102910Z ceeced8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lightly-fast-track-bot

lightly-fast-track-bot Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

✅  Fast Track: all required checks passed — auto-approved.

Guardrail Result Message
frontend/complexity ✅ 0 file(s) checked.
diff-size ✅ PR adds 26 non-test line(s) (limit: 215).
frontend/coverage ✅ 0 file(s) checked.

View the guardrail run

To run the guardrails locally, from fast_track/ run make install once, then make run-guardrails (or GUARDRAILS=<name1>,<name2> make run-guardrails for some guardrails).

Reflects a782b1e.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ceeced87aa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c2a3d71 and a782b1e.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Job submission now uses a registered job name and input instead of a function argument. The in-process runner resolves the job, validates and queues a copy of its input, then passes that input and a progress callback to the job function.

Changes: Named job submission

Layer / File(s) Summary
Resolve and queue named jobs
lightly_studio/src/lightly_studio/jobs/in_process_job_runner.py, lightly_studio/src/lightly_studio/jobs/job_runner.py
submit now accepts a job name and input. The in-process runner resolves the registered function, validates the input, and passes the input and progress callback to the function.
Runner behavior and validation tests
lightly_studio/tests/jobs/helpers.py, lightly_studio/tests/jobs/test_in_process_job_runner.py
Tests use registered jobs and cover input copying, unknown names, non-JSON input, result handling, sequential execution, and database reads and writes.
API and remote test callers
lightly_studio/tests/api/routes/api/v1/test_jobs.py, lightly_studio/tests/transport/remote/test_http_job.py
Tests register jobs and submit them by name with input. Existing success, polling, progress, and failure checks remain.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant InProcessJobRunner
  participant job_registry
  participant RegisteredJobFunction
  Caller->>InProcessJobRunner: submit job name and input
  InProcessJobRunner->>job_registry: resolve job definition
  InProcessJobRunner->>InProcessJobRunner: validate and queue input
  InProcessJobRunner->>RegisteredJobFunction: pass job_input and report_progress
Loading

Possibly related PRs

Merge Risk: Minimal · previous review c2a3d

Job submission now takes a registered job name and JSON input. Unknown names and invalid input are rejected before a job is created. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat: start background jobs by name with JSON input" matches the main change. JobRunner.submit now takes a job name and JSON-valued input mapping instead of a JobFunction, as the raw summar…
Description check Passed The description follows the repository template. It has the 'What has changed and why?' section, which lists the signature change, submit-time validation, and input copying. It has the 'How has it bee…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat: start background jobs by name with JSON input" matches the main change. JobRunner.submit now takes a job name and JSON-valued input mapping instead of a JobFunction, as the raw summary and objectives describe. The title is specific and concise, and it names the two core aspects of the change: start by name and JSON input.

Full details: Description check

Explanation

The description follows the repository template. It has the 'What has changed and why?' section, which lists the signature change, submit-time validation, and input copying. It has the 'How has it been tested?' section, which lists updated tests and new tests for unknown job names, non-JSON input, and input mutation after submit. The CHANGELOG checklist is present, and 'Not needed (internal change)' is checked. The template's placeholder instructions were removed. The description gives no test commands or reproduction steps, which the template asks for. This is a minor gap, so the check still passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c76f3f9 and c2a3d71.

Files selected for processing: 6

  • lightly_studio/src/lightly_studio/jobs/in_process_job_runner.py
  • lightly_studio/src/lightly_studio/jobs/job_runner.py
  • lightly_studio/tests/api/routes/api/v1/test_jobs.py
  • lightly_studio/tests/jobs/helpers.py
  • lightly_studio/tests/jobs/test_in_process_job_runner.py
  • lightly_studio/tests/transport/remote/test_http_job.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

@iunir
iunir force-pushed the iunir-lig-11460-6-submit-by-name branch from ceeced8 to c76f3f9 Compare December 4, 2026 08:54
@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review December 4, 2026 08:54

Fast Track checks no longer pass; dismissing the bot approval.

@iunir
iunir force-pushed the iunir-lig-11460-6-submit-by-name branch from c76f3f9 to c2a3d71 Compare December 4, 2026 09:26
@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review December 4, 2026 09:26

Fast Track checks no longer pass; dismissing the bot approval.

Base automatically changed from iunir-lig-11460-5-job-registry to main December 4, 2026 10:28
iunir added 2 commits December 4, 2026 11:28
Callers with a narrower dict type can submit a job. The job tests register jobs in fewer lines.
@iunir
iunir force-pushed the iunir-lig-11460-6-submit-by-name branch from c2a3d71 to a782b1e Compare December 4, 2026 10:28

This branch has not been deployed

No deployments
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.

1 participant