opensafely-core / opensafely-core/opensafely-cli
Local run of ehrql jobs succeed when codelists out of date
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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