Skip to content

fix: default machine config indexing now works #1979

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

Merged
merged 1 commit into from
Apr 24, 2025
Merged

fix: default machine config indexing now works #1979

merged 1 commit into from
Apr 24, 2025

Conversation

ericallam
Copy link
Member

@ericallam ericallam commented Apr 24, 2025

Summary by CodeRabbit

  • New Features

    • Added support for specifying a machine type in task definitions and configuration.
    • Tasks without a defined machine preset now inherit the machine setting from the global configuration if available.
  • Bug Fixes

    • Fixed an issue with default machine configuration indexing to ensure correct application of machine presets.

Copy link

changeset-bot bot commented Apr 24, 2025

🦋 Changeset detected

Latest commit: 85e8e30

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented Apr 24, 2025

Walkthrough

This update introduces logic to apply a default machine preset from the global configuration to tasks that do not already specify a machine preset. The new behavior is implemented in both the development and managed index worker entry points. Additionally, the configuration and example files in the "hello-world" reference are updated to include explicit machine presets. A new changeset documents these adjustments as a patch for the "trigger.dev" component, specifically addressing default machine configuration indexing.

Changes

File(s) Change Summary
.changeset/spotty-ducks-punch.md Added a changeset documenting a patch update for "trigger.dev" regarding default machine config indexing.
packages/cli-v3/src/entryPoints/dev-index-worker.ts
.../managed-index-worker.ts
Added logic to assign a machine preset from global config to tasks lacking an explicit machine preset.
references/hello-world/src/trigger/example.ts Added machine: "medium-1x" property to the parentTask task definition.
references/hello-world/trigger.config.ts Added machine: "large-1x" property to the exported configuration object.

Sequence Diagram(s)

sequenceDiagram
    participant Config
    participant IndexWorker
    participant Task

    Config->>IndexWorker: Provide global config (may include machine preset)
    IndexWorker->>Task: For each task, check if machine.preset is set
    alt Task has no machine.preset
        IndexWorker->>Task: Assign machine.preset from config
    else Task already has machine.preset
        IndexWorker->>Task: Leave machine.preset unchanged
    end
Loading

Possibly related PRs

  • triggerdotdev/trigger.dev#1321: Addresses applying a default machine preset from global config to tasks lacking one, ensuring consistent machine configuration.
  • triggerdotdev/trigger.dev#1608: Introduces support for specifying machine presets at trigger time, modifying how machine presets are assigned to tasks.

Poem

Hopping through configs, I see,
Machines set as far as the eye can be!
Tasks now inherit, with presets so neat,
No more confusion—defaults can’t be beat.
From "large-1x" to "medium-1x" in a hop,
This rabbit approves—what a clever swap!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
references/hello-world/trigger.config.ts (1)

18-18: Machine preset configuration looks good!

The addition of the machine: "large-1x" configuration sets a global default machine preset that will be applied to all tasks that don't specify their own machine preset.

Consider adding a brief comment above this property to clarify its purpose:

+  // Default machine preset to use for all tasks that don't specify their own
  machine: "large-1x",
packages/cli-v3/src/entryPoints/managed-index-worker.ts (1)

131-145: Default machine preset implementation looks solid.

The implementation correctly applies the global machine preset to tasks that don't have one already defined, following the same pattern used for retry defaults and maxDuration.

Consider adding a comment to clarify the behavior when a task has a machine object but no preset property:

// If the config has a machine preset, we need to apply it to all tasks that don't have a machine preset
if (typeof config.machine === "string") {
  tasks = tasks.map((task) => {
+    // This will also replace any existing machine config without a preset property
    if (typeof task.machine?.preset !== "string") {
      return {
        ...task,
        machine: {
          preset: config.machine,
        },
      } satisfies TaskManifest;
    }

    return task;
  });
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32ff569 and 85e8e30.

📒 Files selected for processing (5)
  • .changeset/spotty-ducks-punch.md (1 hunks)
  • packages/cli-v3/src/entryPoints/dev-index-worker.ts (1 hunks)
  • packages/cli-v3/src/entryPoints/managed-index-worker.ts (1 hunks)
  • references/hello-world/src/trigger/example.ts (1 hunks)
  • references/hello-world/trigger.config.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
.changeset/spotty-ducks-punch.md (1)

1-5: Changeset looks good.

The changeset correctly documents this as a patch update for trigger.dev with an appropriate description of the fix.

references/hello-world/src/trigger/example.ts (1)

40-40: Task-level machine preset looks good.

The addition of machine: "medium-1x" to this task demonstrates how individual tasks can override the global machine preset defined in the config file ("large-1x").

packages/cli-v3/src/entryPoints/dev-index-worker.ts (1)

131-145: Looks good! This change correctly applies the default machine preset config to tasks.

The added code follows the same pattern as the existing conditional blocks for handling retry and maxDuration defaults. It appropriately:

  1. Checks if a global machine preset is configured
  2. Only applies the default to tasks that don't already have a machine preset defined
  3. Preserves other task properties when applying the default

This implementation ensures consistent behavior across all tasks and completes the feature set for applying global defaults.

@nicktrn nicktrn merged commit 30f9352 into main Apr 24, 2025
8 of 12 checks passed
@nicktrn nicktrn deleted the ea-branch-51 branch April 24, 2025 12:38
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