From 90f6465204de5ba45a6ca1fed48e9d7a329777ad Mon Sep 17 00:00:00 2001 From: Andy Rae Date: Tue, 4 Feb 2025 09:40:03 +0000 Subject: [PATCH] Improve developer setup (#68) * Add availability json * Update gitinogre * Add omop-lite * Add contributing * Update gitignore * Add main method and VSCode debug configurations * Add distribution query test configuration * Improve launch json --- .gitignore | 2 ++ .vscode/launch.json | 40 +++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 5 +++++ dev.compose.yml | 10 +++++++++ src/hutch_bunny/cli.py | 4 ++++ src/hutch_bunny/daemon.py | 5 +++++ tests/queries/availability.json | 26 +++++++++++++++++++++ tests/queries/distribution.json | 7 ++++++ 8 files changed, 99 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 CONTRIBUTING.md create mode 100644 tests/queries/availability.json create mode 100644 tests/queries/distribution.json diff --git a/.gitignore b/.gitignore index 15201ac..867e885 100644 --- a/.gitignore +++ b/.gitignore @@ -169,3 +169,5 @@ cython_debug/ # PyPI configuration file .pypirc + +output.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..932b487 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,40 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Bunny Daemon", + "type": "debugpy", + "request": "launch", + "module": "hutch_bunny.daemon", + "justMyCode": true, + "console": "integratedTerminal" + }, + { + "name": "Bunny CLI Availability", + "type": "debugpy", + "request": "launch", + "module": "hutch_bunny.cli", + "args": [ + "--body", + "tests/queries/availability.json", + ], + "justMyCode": true, + "console": "integratedTerminal" + }, + { + "name": "Bunny CLI Distribution", + "type": "debugpy", + "request": "launch", + "module": "hutch_bunny.cli", + "args": [ + "--body", + "tests/queries/distribution.json", + ], + "justMyCode": true, + "console": "integratedTerminal" + } + ] +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..88a7bb7 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing + +Thanks for your interest in contributing! + +Please find guidance to contributing to Bunny in our [documentation](https://health-informatics-uon.github.io/hutch/contributing). diff --git a/dev.compose.yml b/dev.compose.yml index da2f8e5..de4c521 100644 --- a/dev.compose.yml +++ b/dev.compose.yml @@ -8,6 +8,16 @@ services: - 5432:5432 environment: POSTGRES_PASSWORD: postgres + POSTGRES_DB: omop + + omop-lite: + image: ghcr.io/health-informatics-uon/omop-lite + depends_on: + - db + environment: + DB_PASSWORD: postgres + DB_NAME: omop + SYNTHETIC: true adminer: image: wodby/adminer diff --git a/src/hutch_bunny/cli.py b/src/hutch_bunny/cli.py index 9ee9194..ca77227 100644 --- a/src/hutch_bunny/cli.py +++ b/src/hutch_bunny/cli.py @@ -43,3 +43,7 @@ def main() -> None: ) save_to_output(result, args.output) logger.info(f"Saved results to {args.output}") + + +if __name__ == "__main__": + main() diff --git a/src/hutch_bunny/daemon.py b/src/hutch_bunny/daemon.py index df6a63a..b959d37 100644 --- a/src/hutch_bunny/daemon.py +++ b/src/hutch_bunny/daemon.py @@ -7,6 +7,7 @@ from hutch_bunny.core.logger import logger from hutch_bunny.core.setting_database import setting_database + def main() -> None: settings.log_settings() # Setting database connection @@ -74,3 +75,7 @@ def main() -> None: logger.info("Got http status code: %s", response.status_code) time.sleep(settings.POLLING_INTERVAL) + + +if __name__ == "__main__": + main() diff --git a/tests/queries/availability.json b/tests/queries/availability.json new file mode 100644 index 0000000..961e2a3 --- /dev/null +++ b/tests/queries/availability.json @@ -0,0 +1,26 @@ +{ + "task_id": "job-2023-01-13-14: 20: 38-project", + "project": "project_id", + "owner": "user1", + "cohort": { + "groups": [ + { + "rules": [ + { + "varname": "OMOP", + "varcat": "Person", + "type": "TEXT", + "oper": "=", + "value": "8507" + } + ], + "rules_oper": "AND" + } + ], + "groups_oper": "OR" + }, + "collection": "collection_id", + "protocol_version": "v2", + "char_salt": "salt", + "uuid": "unique_id" +} \ No newline at end of file diff --git a/tests/queries/distribution.json b/tests/queries/distribution.json new file mode 100644 index 0000000..d3ba200 --- /dev/null +++ b/tests/queries/distribution.json @@ -0,0 +1,7 @@ +{ + "code": "GENERIC", + "analysis": "DISTRIBUTION", + "uuid": "59952952-c187-432a-981a-b3d35e1a7087", + "collection": "RQ-CC-xuihj7ll-kjlj-3989-b201-587934a89797", + "owner": "user1" +} \ No newline at end of file