Skip to content

feat: uniform handlebar variables for job actions #1855

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 3 commits into from
May 12, 2025

Conversation

sbliven
Copy link
Member

@sbliven sbliven commented Apr 24, 2025

Description

Many job actions accept handlebars templates. This exposes additional variables to the templates and makes accessing variables consistent across all the different scopes that actions are executed in.

All templates now receive the following context:

{
  request: JobDto,
  job?: JobClass,
  datasets?: DatasetClass[],
  env: Record<string,string?>
}

Before, {{this}} would correspond to different objects depending on how the action is
called; either a DTO or a Job or even a Dataset. Now these are accessed
consistently through top-level fields; thus {{id}} becomes {{job.id}},
{{jobParams}} becomes {{request.jobParams}}, etc.

This also adds access to environmental variables via {{env}}, making
it easier to include secrets actions without hard-coding them.

Tests and example files should be up-to-date.

Motivation

Adding env makes it easier to reference secrets securely without putting them in jobConfig.yaml.

Having a shared context among all jobs is also convenient for caching (eg of the datasets)

Fixes

Changes:

  • Add a new top-level variable to all job templates

Tests included

  • Included for each change/fix?
  • Passing?

Documentation

  • swagger documentation updated (required for API changes)
  • official documentation updated

official documentation info

SciCatProject/documentation#70

sbliven added 2 commits April 24, 2025 13:38
The change is most visible in handlebars templates. Before, `{{this}}`
would correspond to different objects depending on how the action is
called; either a DTO or a Job or even a Dataset. Now these are accessed
consistently through top-level fields; thus `{{id}}` becomes `{{job.id}}`,
`{{jobParams}}` becomes `{{request.jobParams}}`, etc.

This also adds access to environmental variables via `{{env}}`, making
it easier to include secrets actions without hard-coding them.

Tests and example files should be up-to-date.
Datasets get cached in the context, meaning that they only need to be
fetched once for all actions.
@sbliven sbliven self-assigned this Apr 24, 2025
@sbliven sbliven changed the title feat: make job templates consistent feat: uniform handlebar variables for job actions Apr 24, 2025
sbliven added a commit to sbliven/scicat-documentation that referenced this pull request Apr 24, 2025
sbliven added a commit to sbliven/scicat-documentation that referenced this pull request Apr 24, 2025
@sbliven sbliven marked this pull request as ready for review April 24, 2025 17:33
@sbliven sbliven requested a review from despadam April 24, 2025 17:34
Copy link
Member

@despadam despadam left a comment

Choose a reason for hiding this comment

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

I like this a lot 👍

@sbliven sbliven merged commit e681d0e into SciCatProject:master May 12, 2025
13 checks passed
@sbliven sbliven deleted the job-context branch May 14, 2025 11:17
sbliven added a commit to sbliven/scicat-documentation that referenced this pull request May 14, 2025
sbliven added a commit to SciCatProject/documentation that referenced this pull request May 14, 2025
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