The current T1OO filtering logic predates the more generalised permissions system and instead uses an extra query parameter on the database URL:
|
def modify_dsn(self, dsn): |
|
""" |
|
Removes the `opensafely_include_t1oo` parameter if present and uses it to set |
|
the `include_t1oo` attribute accordingly |
|
""" |
Now that we need to implement parallel logic for EMIS this is a good point at which to move the TPP logic to use the permissions system. We certainly don't want to be trying to implement the query parameter version in EMIS, and having divergent implementations isn't ideal.
Here's an outline of a plan for doing so. I've only mention the production code changes, but each of these will require test changes as well. Where the code comments mention specific bits of documentation that need updating then that should be done as well. Each step presumes that the previous step has been merged and deployed.
1. Update Job Server to send the right permissions
The first step is to update Job Server so that it sends the right permissions (while also leaving the old code in place). That involves adding an analysis_scope_for_project function (parallel to the one for ndoo) to the t100 module. And then including the t1oo module in the list of "population permission" modules here. The permission name should be include_t1oo.
2. Update ehrQL to respect both old and new permissions
That means adding a line here:
|
include_ndoo = "include_ndoo" in self.permissions |
include_t1oo = self.include_t1oo or "include_t1oo" in self.permissions
And changing self.include_t1oo to include_t1oo here:
|
if not self.include_t1oo: |
3. Remove old code from Job Server
This method can just be replaced with return "default", and the project_is_permitted_to_use_t1oo_data function removed entirely.
4. Remove old code from ehrQL
We can then remove the entire modify_dsn method, and in fact remove the modify_dsn hook from BaseBackend altogether. The self.include_t1oo attribute can go as well.
5. Tidy up
We can remove the INCLUDE_T1OO_DATABASE_URL from the secrets template. And remove the config value from ~/config/02_secrets.env in the TPP backend as well.
We can remove include_t1oo from the VALID_DATABASE_NAMES here.
The current T1OO filtering logic predates the more generalised permissions system and instead uses an extra query parameter on the database URL:
ehrql/ehrql/backends/tpp.py
Lines 114 to 118 in cbb7628
Now that we need to implement parallel logic for EMIS this is a good point at which to move the TPP logic to use the permissions system. We certainly don't want to be trying to implement the query parameter version in EMIS, and having divergent implementations isn't ideal.
Here's an outline of a plan for doing so. I've only mention the production code changes, but each of these will require test changes as well. Where the code comments mention specific bits of documentation that need updating then that should be done as well. Each step presumes that the previous step has been merged and deployed.
1. Update Job Server to send the right permissions
The first step is to update Job Server so that it sends the right permissions (while also leaving the old code in place). That involves adding an
analysis_scope_for_projectfunction (parallel to the one forndoo) to thet100module. And then including thet1oomodule in the list of "population permission" modules here. The permission name should beinclude_t1oo.2. Update ehrQL to respect both old and new permissions
That means adding a line here:
ehrql/ehrql/backends/tpp.py
Line 136 in cbb7628
And changing
self.include_t1ootoinclude_t1oohere:ehrql/ehrql/backends/tpp.py
Line 152 in cbb7628
3. Remove old code from Job Server
This method can just be replaced with
return "default", and theproject_is_permitted_to_use_t1oo_datafunction removed entirely.4. Remove old code from ehrQL
We can then remove the entire
modify_dsnmethod, and in fact remove themodify_dsnhook from BaseBackend altogether. Theself.include_t1ooattribute can go as well.5. Tidy up
We can remove the
INCLUDE_T1OO_DATABASE_URLfrom the secrets template. And remove the config value from~/config/02_secrets.envin the TPP backend as well.We can remove
include_t1oofrom the VALID_DATABASE_NAMES here.