opensafely-core / opensafely-core/opensafely-cli

Local run of ehrql jobs succeed when codelists out of date

Open
#404 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2
Forks
5
Avg merge
2d 1h
Merged PRs (30d)
4

Description

Reported by a user on Slack.

An ehrql job succeeded locally when run with opensafely run but failed when submitted due to the used codelists being out of date.
If the user ran opensafely codelist check locally, they would have been informed of the out of date codelists, but perhaps we can fail the ehrql job (as we would in prod), so that we don't rely on users remembering to run codelist check themselves.

At the moment, the JobRequest.codelist_ok param is hard-coded to True in local run:
https://github.com/opensafely-core/opensafely-cli/blob/01b95fc00a459b2d0112acc61822a91a1c526c62/opensafely/jobrunner/cli/local_run.py#L455-L468

It might be possible to actually check the codelists instead.

Note that this very minimum code seems to already produce the desired behaviour of causing the job to fail locally:

def create_job_request_and_jobs(project_dir, actions, force_run_dependencies):

    from opensafely.codelists import check

    job_request = JobRequest(
        id=random_id(),
        repo_url=str(project_dir),
        commit=None,
        requested_actions=actions,
        cancelled_actions=[],
        workspace=project_dir.name,
        codelists_ok=check(),
        database_name="dummy",
        force_run_dependencies=force_run_dependencies,
        branch="",
        original={"created_by": getuser()},
    )

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in opensafely/jobrunner/cli/local_run.py around the hard-coded JobRequest.codelist_ok value used by opensafely run. Review opensafely.codelists.check and the local job-request entry point, then verify that an ehrql job with out-of-date codelists fails locally as it does in production, without requiring a separate codelist check.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.