Skip to content

Commit

Permalink
Merge pull request #606 from opensafely-core/add-ehrql
Browse files Browse the repository at this point in the history
feat: Add ehrql to allowed images
  • Loading branch information
rebkwok authored Apr 20, 2023
2 parents 851a533 + d39df53 commit a326d29
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions jobrunner/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def _is_valid_backend_name(name):
ALLOWED_IMAGES = {
"cohortextractor",
"databuilder",
"ehrql",
"stata-mp",
"r",
"jupyter",
Expand Down
2 changes: 1 addition & 1 deletion jobrunner/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def is_extraction_command(args, require_version=None):
if args[0].startswith("cohortextractor:"):
version_found = 1
# databuilder is a rebranded cohortextractor-v2.
elif args[0].startswith("databuilder:"):
elif args[0].startswith("databuilder:") or args[0].startswith("ehrql:"):
version_found = 2

# If we're not looking for a specific version then return True if any
Expand Down
1 change: 1 addition & 0 deletions jobrunner/lib/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def requires_db_access(args):
valid_commands = {
"cohortextractor": ("generate_cohort", "generate_codelist_report"),
"databuilder": ("generate-dataset",),
"ehrql": ("generate-dataset",),
"sqlrunner": None, # all commands are valid
}
if len(args) <= 1:
Expand Down
9 changes: 9 additions & 0 deletions scripts/update-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@ docker pull docker-proxy.opensafely.org/opensafely-core/$1
docker tag docker-proxy.opensafely.org/opensafely-core/$1 ghcr.io/opensafely-core/$1
# temp b/w compat tag
docker tag docker-proxy.opensafely.org/opensafely-core/$1 ghcr.io/opensafely/$1

# If the image being updated is databuilder, make sure we get the aliased ehrql tag too
if [[ $1 == databuilder* ]]; then
image=$(echo "$1" | sed -r 's/[databuilder]+/ehrql/g')
echo "Updating ehrql image: $image"
docker pull docker-proxy.opensafely.org/opensafely-core/$image
docker tag docker-proxy.opensafely.org/opensafely-core/$image ghcr.io/opensafely-core/$image
fi

docker image prune --force
3 changes: 3 additions & 0 deletions tests/test_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
(1, ["cohortextractor:latest", "generate_cohort"], True),
(1, ["cohortextractor-v2:latest", "generate_cohort"], False),
(1, ["databuilder:latest", "generate_dataset"], False),
(1, ["ehrql:v0", "generate_dataset"], False),
(2, ["cohortextractor:latest", "generate_cohort"], False),
# cohortextractor-v2 is no longer supported
(2, ["cohortextractor-v2:latest", "generate_cohort"], False),
(2, ["databuilder:latest", "generate_dataset"], True),
(2, ["ehrql:v0", "generate_dataset"], True),
],
)
def test_is_extraction_command_with_version(args, require_version, desired_outcome):
Expand All @@ -28,6 +30,7 @@ def test_is_extraction_command_with_version(args, require_version, desired_outco
# cohortextractor-v2 is no longer supported
(["cohortextractor-v2:latest", "generate_cohort"], False),
(["databuilder:latest", "generate_dataset"], True),
(["ehrql:v0", "generate_dataset"], True),
(["test"], False),
(["test", "generate_cohort"], False),
(["test", "generate_dataset"], False),
Expand Down

0 comments on commit a326d29

Please sign in to comment.