Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Cohorts UI #691

Draft
wants to merge 78 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
5ceb5f6
In progress
vivbak Nov 15, 2023
d7ef222
In progress
vivbak Nov 15, 2023
da2f9db
Cohort GraphQL Skeleton -- functional now
vivbak Nov 16, 2023
c2ff6c9
Merge branch 'dev' into custom-cohorts
vivbak Nov 16, 2023
6f1d9da
This should go in another PR
vivbak Nov 16, 2023
a956cee
Merge branch 'dev' into custom-cohorts
vivbak Nov 17, 2023
25155ab
ignore venv
daniaki Nov 23, 2023
7a5d978
Updated docker mariadb setup instructions
daniaki Nov 23, 2023
d5103a1
support for `name`, `derived_from` & other fields
daniaki Nov 23, 2023
9d655e9
Fix error if applying `ord` to int
daniaki Nov 23, 2023
f69cde0
Add all fields to model
daniaki Nov 23, 2023
5d24669
Set empty dict to fix GraphQL non-null error
daniaki Nov 23, 2023
32fc088
Fix error applying `ord` to int
daniaki Nov 23, 2023
7dc373d
Add `name` to `cohort` table
daniaki Nov 23, 2023
312c6f8
version bump
daniaki Nov 23, 2023
9fb6a06
Formatting; cohort GQL schema
daniaki Nov 27, 2023
57afc9f
cohort layer update
daniaki Nov 27, 2023
203a49b
cohort db table update
daniaki Nov 27, 2023
60798c1
CohortBuilder route
daniaki Nov 27, 2023
5af95cc
Single SG ID form
daniaki Nov 27, 2023
c5cdb17
SG ID from project(s) form
daniaki Nov 27, 2023
58c80d4
Cohort Builder page
daniaki Nov 27, 2023
003ffff
Re-usable SG scrolling table
daniaki Nov 27, 2023
4cdfde0
types definition
daniaki Nov 27, 2023
3f27185
Add link to nav bar to cohort builder
daniaki Nov 27, 2023
f153df2
Add substring search
daniaki Nov 27, 2023
4db1ca7
Merge branch 'custom-cohorts' of github.com:populationgenomics/sample…
vivbak Nov 27, 2023
a0385d5
Formatting; add assay filter on sample
daniaki Nov 28, 2023
7858fc7
Allow hashable assay filter when `meta` present
daniaki Nov 28, 2023
39e0c8b
Type for project
daniaki Nov 28, 2023
adce34b
Add GQL query to project form
daniaki Nov 28, 2023
b4b0a5b
Add GQL query to ID form
daniaki Nov 28, 2023
7f0b62e
Handle form submission
daniaki Nov 28, 2023
9f361ef
Atomic transaction
daniaki Nov 28, 2023
cd94354
Put query params in POST body
daniaki Nov 28, 2023
1747882
add APIError type
daniaki Nov 28, 2023
8217790
Add TODO note; add loader to search button
daniaki Nov 28, 2023
d6017cb
merge dupe sgs from search results
daniaki Nov 28, 2023
4a334d5
Use auto-gen API; better error handling
daniaki Nov 28, 2023
7f24180
clean up imports
daniaki Nov 28, 2023
ada2c01
Make inputs reactive
daniaki Nov 28, 2023
7d1c8eb
Cohort detail view
daniaki Nov 28, 2023
706cf01
import updates
daniaki Nov 28, 2023
05066b0
add detail route
daniaki Nov 28, 2023
d60db2a
use with router hooks
daniaki Nov 28, 2023
654b9ae
exclude ids input
daniaki Nov 28, 2023
c002f88
navigate to new detail vie
daniaki Nov 28, 2023
af8f4d9
make project required
daniaki Nov 28, 2023
f1e491c
Add space between muck and msg
daniaki Nov 28, 2023
deaa491
Get project info
daniaki Nov 28, 2023
d2662f2
Convert ids to int to fix not found error
daniaki Nov 28, 2023
1ca9df4
cohort project resolver
daniaki Nov 28, 2023
c5f0fd8
Update table rendering logic
daniaki Nov 28, 2023
573b57b
Update table rendering logic
daniaki Nov 28, 2023
49a1245
Add search result info in warning box
daniaki Nov 28, 2023
2b9ba76
Linter fixes
daniaki Dec 3, 2023
0172dff
formatting
daniaki Dec 4, 2023
62ea338
Merge branch 'dev' into custom-cohorts
daniaki Dec 4, 2023
4b0661a
lint fix
daniaki Dec 4, 2023
cfd21eb
unused import
daniaki Dec 4, 2023
7a3611c
Tmp fix for billing query inside NavBar
daniaki Dec 4, 2023
bc5e0b9
Merge branch 'custom-cohorts' of github.com:populationgenomics/sample…
vivbak Jan 10, 2024
32fac2b
Custom cohorts SG query optimisation (#630)
daniaki Jan 31, 2024
146e6b2
Merge branch 'custom-cohorts' of github.com:populationgenomics/sample…
vivbak Jan 31, 2024
b8e88c3
Merge branch dev into custom-cohorts
vivbak Jan 31, 2024
dcd5e68
update dbbase import
vivbak Jan 31, 2024
9ef10ef
Update to_sql signature to match superclass. An attempt at pleasing t…
vivbak Feb 5, 2024
f82f816
Fix click overwriting param to None when not specified
vivbak Feb 8, 2024
9e33d7f
Create endpoint to create cohort from criteria - Project/s
vivbak Feb 16, 2024
3fdc803
Fix query cohort, call connection directly
vivbak Feb 16, 2024
558b073
Add further criteria to create_cohort_from_criteria endpoint
vivbak Feb 22, 2024
3b00f6c
Fix the linter, import order, spaces, etc
vivbak Feb 22, 2024
ae3c271
Remove AddFromIdListForm.tsx
vivbak Feb 26, 2024
baa77e8
Add excalamtion to push change
vivbak Feb 26, 2024
735eaed
Merge branch custom-cohorts into custom-cohorts-ui
vivbak Feb 26, 2024
9a4668f
Delete AddFromIDListForm
vivbak Feb 26, 2024
300544e
Add new character to trigger merge commit
vivbak Feb 26, 2024
cd7c2ff
Merge branch custom-cohorts into custom-cohorts-ui
vivbak Feb 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
db/postgres*.jar
.vscode/
env/
venv/
__pycache__/
*.pyc
.DS_Store
Expand Down
56 changes: 37 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ export PATH="$HB_PREFIX/opt/mariadb@10.8/bin:$PATH"
If you installed all the software through brew and npm
like this guide suggests, your `.zshrc` may look like this:


```shell
alias openapi-generator="npx @openapitools/openapi-generator-cli"

Expand Down Expand Up @@ -269,6 +268,12 @@ Pull mariadb image
docker pull mariadb:10.8.3
```

If you wish, install the mysql-client using homebrew (or an equivalent linux command) so you can connect to the MariaDB server running via Docker:

```bash
brew install mysql-client
```

Run a mariadb container that will server your database. `-p 3307:3306` remaps the port to 3307 in case if you local MySQL is already using 3306

```bash
Expand All @@ -283,10 +288,24 @@ mysql --host=127.0.0.1 --port=3307 -u root -e 'CREATE DATABASE sm_dev;'
mysql --host=127.0.0.1 --port=3307 -u root -e 'show databases;'
```

Go into the `db/` subdirectory, download the `mariadb-java-client` and create the schema using liquibase:
Similar to the previous section, we need to create the `sm_api` user, and set the corect roles and privileges:

```bash
mysql --host=127.0.0.1 --port=3307 -u root --execute "
CREATE USER sm_api@'%';
CREATE USER sm_api@localhost;
CREATE ROLE sm_api_role;
GRANT sm_api_role TO sm_api@'%';
GRANT sm_api_role TO sm_api@localhost;
SET DEFAULT ROLE sm_api_role FOR sm_api@'%';
SET DEFAULT ROLE sm_api_role FOR sm_api@localhost;
GRANT ALL PRIVILEGES ON sm_dev.* TO sm_api_role;
"
```

Go into the `db/` subdirectory, download the `mariadb-java-client` and create the schema using liquibase:

```bash
pushd db/
wget https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/3.0.3/mariadb-java-client-3.0.3.jar
liquibase \
Expand Down Expand Up @@ -341,22 +360,22 @@ The following `launch.json` is a good base to debug the web server in VSCode:

```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Run API",
"type": "python",
"request": "launch",
"module": "api.server",
"justMyCode": false,
"env": {
"SM_ALLOWALLACCESS": "true",
"SM_LOCALONLY_DEFAULTUSER": "<user>-local",
"SM_ENVIRONMENT": "local",
"SM_DEV_DB_USER": "sm_api",
}
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Run API",
"type": "python",
"request": "launch",
"module": "api.server",
"justMyCode": false,
"env": {
"SM_ALLOWALLACCESS": "true",
"SM_LOCALONLY_DEFAULTUSER": "<user>-local",
"SM_ENVIRONMENT": "local",
"SM_DEV_DB_USER": "sm_api"
}
}
]
}
```

Expand Down Expand Up @@ -420,7 +439,6 @@ npm start

This will start a web server using Vite, running on [localhost:5173](http://localhost:5173).


### OpenAPI and Swagger

The Web API uses `apispec` with OpenAPI3 annotations on each route to describe interactions with the server. We can generate a swagger UI and an installable
Expand Down
10 changes: 10 additions & 0 deletions api/graphql/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class GraphQLFilter(Generic[T]):
gte: T | None = None
lt: T | None = None
lte: T | None = None
contains: T | None = None
icontains: T | None = None

def all_values(self):
"""
Expand All @@ -38,6 +40,10 @@ def all_values(self):
v.append(self.lt)
if self.lte:
v.append(self.lte)
if self.contains:
v.append(self.contains)
if self.icontains:
v.append(self.icontains)

return v

Expand All @@ -53,6 +59,8 @@ def to_internal_filter(self, f: Callable[[T], Any] = None):
gte=f(self.gte) if self.gte else None,
lt=f(self.lt) if self.lt else None,
lte=f(self.lte) if self.lte else None,
contains=f(self.contains) if self.contains else None,
icontains=f(self.icontains) if self.icontains else None,
)

return GenericFilter(
Expand All @@ -63,6 +71,8 @@ def to_internal_filter(self, f: Callable[[T], Any] = None):
gte=self.gte,
lt=self.lt,
lte=self.lte,
contains=self.contains,
icontains=self.icontains,
)


Expand Down
7 changes: 5 additions & 2 deletions api/graphql/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,13 @@ async def load_projects_for_ids(project_ids: list[int], connection) -> list[Proj
"""
pttable = ProjectPermissionsTable(connection)
projects = await pttable.get_and_check_access_to_projects_for_ids(
user=connection.user, project_ids=project_ids, readonly=True
user=connection.author, project_ids=project_ids, readonly=True
)

p_by_id = {p.id: p for p in projects}
return [p_by_id.get(p) for p in project_ids]
projects = [p_by_id.get(p) for p in project_ids]

return [p for p in projects if p is not None]


@connected_data_loader(LoaderKeys.FAMILIES_FOR_PARTICIPANTS)
Expand Down
Loading
Loading