Skip to content

Commit

Permalink
Merge pull request #551 from UW-GAC/main
Browse files Browse the repository at this point in the history
Deploy to stage
  • Loading branch information
amstilp authored Apr 30, 2024
2 parents 21fb309 + cad7dfb commit 885d971
Show file tree
Hide file tree
Showing 119 changed files with 4,020 additions and 5,133 deletions.
5 changes: 5 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ DJANGO_EMAIL_PORT=
DJANGO_EMAIL_HOST_USER=
DJANGO_EMAIL_HOST_PASSWORD=
DJANGO_EMAIL_USE_TLS=

# drupal api
DRUPAL_API_CLIENT_ID=
DRUPAL_API_CLIENT_SECRET=
DRUPAL_API_REL_PATH=
23 changes: 1 addition & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,6 @@ concurrency:
cancel-in-progress: true

jobs:
linter:
runs-on: ubuntu-latest
steps:

- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: pip
cache-dependency-path: |
requirements/requirements.txt
requirements/test-requirements.txt
# Run all pre-commit hooks on all the files.
# Getting only staged files can be tricky in case a new PR is opened
# since the action is run on a branch in detached head state
- name: Install and Run Pre-commit
uses: pre-commit/[email protected]

pytest-mariadb:
runs-on: ubuntu-latest
Expand All @@ -50,7 +29,7 @@ jobs:
# ahead of planned upgrades we can add versions as
# needed
python-version: [3.8]
mariadb-version: ["10.4"]
mariadb-version: ["10.4", "10.5"]

services:
mysql:
Expand Down
23 changes: 8 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,15 @@ repos:
- id: end-of-file-fixer
- id: check-yaml

- repo: https://github.com/psf/black
rev: 22.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.2
hooks:
- id: black

- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
args: ['--config=setup.cfg']
additional_dependencies: [flake8-isort]
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format

- repo: https://github.com/gitleaks/gitleaks
rev: v8.16.1
Expand Down
20 changes: 20 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
line-length = 120
exclude = [
"**/migrations/**",
"*/static/CACHE/*",
"venv",
"docs",
]

[lint]
extend-select = [
"E",
"F",
"W", # pycodestyle warnings
"I", # isort
"DJ", # flake8-django
"E501", # line-too-long
]

[lint.isort]
known-first-party = ["primed", "config", ]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

[![Black code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/UW-GAC/gregor-django/main.svg)](https://results.pre-commit.ci/latest/github/UW-GAC/gregor-django/main)

[![image](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)

[![Built with Cookiecutter Django](https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg?logo=cookiecutter)](https://github.com/pydanny/cookiecutter-django/)
Expand Down
44 changes: 11 additions & 33 deletions add_cdsa_example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@
major_version = factories.AgreementMajorVersionFactory.create(version=1)

# Create some agreement versions
v10 = factories.AgreementVersionFactory.create(
major_version=major_version, minor_version=0
)
v11 = factories.AgreementVersionFactory.create(
major_version=major_version, minor_version=1
)
v10 = factories.AgreementVersionFactory.create(major_version=major_version, minor_version=0)
v11 = factories.AgreementVersionFactory.create(major_version=major_version, minor_version=1)

# Create a couple signed CDSAs.
dup = DataUsePermission.objects.get(abbreviation="GRU")
Expand All @@ -57,9 +53,7 @@
signed_agreement__version=v10,
study_site=StudySite.objects.get(short_name="CC"),
)
GroupGroupMembershipFactory.create(
parent_group=cdsa_group, child_group=cdsa_1001.signed_agreement.anvil_access_group
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1001.signed_agreement.anvil_access_group)

cdsa_1002 = factories.MemberAgreementFactory.create(
signed_agreement__cc_id=1002,
Expand All @@ -70,9 +64,7 @@
signed_agreement__version=v10,
study_site=StudySite.objects.get(short_name="CARDINAL"),
)
GroupGroupMembershipFactory.create(
parent_group=cdsa_group, child_group=cdsa_1002.signed_agreement.anvil_access_group
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1002.signed_agreement.anvil_access_group)

cdsa_1003 = factories.MemberAgreementFactory.create(
signed_agreement__cc_id=1003,
Expand All @@ -83,9 +75,7 @@
signed_agreement__version=v10,
study_site=StudySite.objects.get(short_name="CARDINAL"),
)
GroupGroupMembershipFactory.create(
parent_group=cdsa_group, child_group=cdsa_1003.signed_agreement.anvil_access_group
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1003.signed_agreement.anvil_access_group)

cdsa_1004 = factories.MemberAgreementFactory.create(
signed_agreement__cc_id=1004,
Expand All @@ -96,9 +86,7 @@
signed_agreement__version=v11,
study_site=StudySite.objects.get(short_name="CARDINAL"),
)
GroupGroupMembershipFactory.create(
parent_group=cdsa_group, child_group=cdsa_1004.signed_agreement.anvil_access_group
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1004.signed_agreement.anvil_access_group)

cdsa_1005 = factories.DataAffiliateAgreementFactory.create(
signed_agreement__cc_id=1005,
Expand All @@ -108,9 +96,7 @@
study=Study.objects.get(short_name="Amish"),
signed_agreement__version=v10,
)
GroupGroupMembershipFactory.create(
parent_group=cdsa_group, child_group=cdsa_1005.signed_agreement.anvil_access_group
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1005.signed_agreement.anvil_access_group)

cdsa_1006 = factories.DataAffiliateAgreementFactory.create(
signed_agreement__cc_id=1006,
Expand All @@ -122,9 +108,7 @@
additional_limitations="This data can only be used for testing the app.",
requires_study_review=True,
)
GroupGroupMembershipFactory.create(
parent_group=cdsa_group, child_group=cdsa_1006.signed_agreement.anvil_access_group
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1006.signed_agreement.anvil_access_group)

cdsa_1007 = factories.DataAffiliateAgreementFactory.create(
signed_agreement__cc_id=1007,
Expand All @@ -135,9 +119,7 @@
study=Study.objects.get(short_name="MESA"),
signed_agreement__version=v10,
)
GroupGroupMembershipFactory.create(
parent_group=cdsa_group, child_group=cdsa_1007.signed_agreement.anvil_access_group
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1007.signed_agreement.anvil_access_group)

cdsa_1008 = factories.DataAffiliateAgreementFactory.create(
signed_agreement__cc_id=1008,
Expand All @@ -148,9 +130,7 @@
study=Study.objects.get(short_name="MESA"),
signed_agreement__version=v10,
)
GroupGroupMembershipFactory.create(
parent_group=cdsa_group, child_group=cdsa_1008.signed_agreement.anvil_access_group
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1008.signed_agreement.anvil_access_group)

cdsa_1009 = factories.NonDataAffiliateAgreementFactory.create(
signed_agreement__cc_id=1009,
Expand Down Expand Up @@ -236,8 +216,6 @@
cdsa_workspace_3 = factories.CDSAWorkspaceFactory.create(
workspace__billing_project__name="demo-primed-cdsa",
workspace__name="DEMO_PRIMED_CDSA_ARIC_1",
study=Study.objects.create(
short_name="ARIC", full_name="Atherosclerosis Risk in Communities"
),
study=Study.objects.create(short_name="ARIC", full_name="Atherosclerosis Risk in Communities"),
data_use_permission=dup,
)
32 changes: 8 additions & 24 deletions add_collaborative_analysis_example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,15 @@


# Add accounts to the auth domains.
account_1 = AccountFactory.create(
user__name="Adrienne", verified=True, email="[email protected]"
)
account_2 = AccountFactory.create(
user__name="Ben", verified=True, email="[email protected]"
)
account_3 = AccountFactory.create(
user__name="Matt", verified=True, email="[email protected]"
)
account_4 = AccountFactory.create(
user__name="Stephanie", verified=True, email="[email protected]"
)
account_1 = AccountFactory.create(user__name="Adrienne", verified=True, email="[email protected]")
account_2 = AccountFactory.create(user__name="Ben", verified=True, email="[email protected]")
account_3 = AccountFactory.create(user__name="Matt", verified=True, email="[email protected]")
account_4 = AccountFactory.create(user__name="Stephanie", verified=True, email="[email protected]")

# Set up collab analysis workspace one
# analyst group
GroupAccountMembershipFactory.create(
account=account_1, group=collaborative_analysis_workspace_1.analyst_group
)
GroupAccountMembershipFactory.create(
account=account_2, group=collaborative_analysis_workspace_1.analyst_group
)
GroupAccountMembershipFactory.create(account=account_1, group=collaborative_analysis_workspace_1.analyst_group)
GroupAccountMembershipFactory.create(account=account_2, group=collaborative_analysis_workspace_1.analyst_group)
# auth domains
GroupAccountMembershipFactory.create(
account=account_1,
Expand All @@ -84,12 +72,8 @@

# Set up collab analysis workspace two
# analyst group
GroupAccountMembershipFactory.create(
account=account_3, group=collaborative_analysis_workspace_2.analyst_group
)
GroupAccountMembershipFactory.create(
account=account_4, group=collaborative_analysis_workspace_2.analyst_group
)
GroupAccountMembershipFactory.create(account=account_3, group=collaborative_analysis_workspace_2.analyst_group)
GroupAccountMembershipFactory.create(account=account_4, group=collaborative_analysis_workspace_2.analyst_group)
# auth domains
GroupAccountMembershipFactory.create(
account=account_3,
Expand Down
28 changes: 7 additions & 21 deletions add_dbgap_example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,13 @@

# Studies
fhs = StudyFactory.create(short_name="FHS", full_name="Framingham Heart Study")
mesa = StudyFactory.create(
short_name="MESA", full_name="Multi-Ethnic Study of Atherosclerosis"
)
aric = StudyFactory.create(
short_name="ARIC", full_name="Atherosclerosis Risk in Communities"
)
mesa = StudyFactory.create(short_name="MESA", full_name="Multi-Ethnic Study of Atherosclerosis")
aric = StudyFactory.create(short_name="ARIC", full_name="Atherosclerosis Risk in Communities")

# dbGaP study accessions
dbgap_study_accession_fhs = factories.dbGaPStudyAccessionFactory.create(
dbgap_phs=7, studies=[fhs]
)
dbgap_study_accession_mesa = factories.dbGaPStudyAccessionFactory.create(
dbgap_phs=209, studies=[mesa]
)
dbgap_study_accession_aric = factories.dbGaPStudyAccessionFactory.create(
dbgap_phs=280, studies=[aric]
)
dbgap_study_accession_fhs = factories.dbGaPStudyAccessionFactory.create(dbgap_phs=7, studies=[fhs])
dbgap_study_accession_mesa = factories.dbGaPStudyAccessionFactory.create(dbgap_phs=209, studies=[mesa])
dbgap_study_accession_aric = factories.dbGaPStudyAccessionFactory.create(dbgap_phs=280, studies=[aric])


# Create some dbGaP workspaces.
Expand Down Expand Up @@ -78,9 +68,7 @@
dbgap_project_id=33119,
)
# Add a snapshot
dar_snapshot_1 = factories.dbGaPDataAccessSnapshotFactory.create(
dbgap_application=dbgap_application_1
)
dar_snapshot_1 = factories.dbGaPDataAccessSnapshotFactory.create(dbgap_application=dbgap_application_1)
# Add some data access requests.
dar_1_1 = factories.dbGaPDataAccessRequestForWorkspaceFactory.create(
dbgap_workspace=workspace_fhs_1,
Expand Down Expand Up @@ -112,9 +100,7 @@
dbgap_project_id=33371,
)
# Add a snapshot
dar_snapshot_2 = factories.dbGaPDataAccessSnapshotFactory.create(
dbgap_application=dbgap_application_2
)
dar_snapshot_2 = factories.dbGaPDataAccessSnapshotFactory.create(dbgap_application=dbgap_application_2)
# Add some data access requests, only for FHS.
dar_1_1 = factories.dbGaPDataAccessRequestForWorkspaceFactory.create(
dbgap_workspace=workspace_fhs_1,
Expand Down
44 changes: 44 additions & 0 deletions add_phenotype_inventory_input_example_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Temporary script to create some test data.
# Run with: python manage.py shell < add_phenotype_inventory_input_example_data.py

from anvil_consortium_manager.tests.factories import (
ManagedGroupFactory,
WorkspaceGroupSharingFactory,
)

from primed.cdsa.tests.factories import CDSAWorkspaceFactory
from primed.dbgap.tests.factories import dbGaPWorkspaceFactory
from primed.miscellaneous_workspaces.tests.factories import OpenAccessWorkspaceFactory
from primed.primed_anvil.tests.factories import StudyFactory

# Create a dbGaP workspace.
fhs = StudyFactory.create(short_name="FHS", full_name="Framingham Heart Study")
workspace_dbgap = dbGaPWorkspaceFactory.create(
dbgap_study_accession__dbgap_phs=7,
dbgap_study_accession__studies=[fhs],
dbgap_version=33,
dbgap_participant_set=12,
dbgap_consent_code=1,
dbgap_consent_abbreviation="HMB",
workspace__name="DBGAP_FHS_v33_p12_HMB",
)


# Create a CDSA workspace.
workspace_cdsa = CDSAWorkspaceFactory.create(
study__short_name="MESA",
workspace__name="CDSA_MESA_HMB",
)

# Create an open access workspace
workspace_open_access = OpenAccessWorkspaceFactory.create(
workspace__name="OPEN_ACCESS_FHS",
)
workspace_open_access.studies.add(fhs)


# Share workspaces with PRIMED_ALL
primed_all = ManagedGroupFactory.create(name="PRIMED_ALL")
WorkspaceGroupSharingFactory.create(workspace=workspace_dbgap.workspace, group=primed_all)
WorkspaceGroupSharingFactory.create(workspace=workspace_cdsa.workspace, group=primed_all)
WorkspaceGroupSharingFactory.create(workspace=workspace_open_access.workspace, group=primed_all)
Loading

0 comments on commit 885d971

Please sign in to comment.