Skip to content

Commit

Permalink
Merge dependabot/pip/mypy-1.10.1 into combined-prs-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jul 1, 2024
2 parents 24d3369 + 4f031aa commit e5db17c
Show file tree
Hide file tree
Showing 55 changed files with 8,850 additions and 1,914 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.9
rev: v0.4.10
hooks:
# Run the linter.
- id: ruff
Expand Down
94 changes: 64 additions & 30 deletions add_cdsa_example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,28 @@
dum = DataUseModifier.objects.get(abbreviation="NPU")

# Create some study sites.
StudySiteFactory.create(short_name="CC", full_name="Coordinating Center")
StudySiteFactory.create(short_name="CARDINAL", full_name="CARDINAL")
try:
cc = StudySite.objects.get(short_name="CC")
except StudySite.DoesNotExist:
cc = StudySiteFactory.create(short_name="CC", full_name="Coordinating Center")
try:
cardinal = StudySite.objects.get(short_name="CARDINAL")
except StudySite.DoesNotExist:
cardinal = StudySiteFactory.create(short_name="CARDINAL", full_name="CARDINAL")

# Create some studies.
StudyFactory.create(short_name="Amish", full_name="Amish")
StudyFactory.create(short_name="MESA", full_name="MESA")
try:
amish = Study.objects.get(short_name="Amish")
except Study.DoesNotExist:
amish = StudyFactory.create(short_name="Amish", full_name="Amish")
try:
mesa = Study.objects.get(short_name="MESA")
except Study.DoesNotExist:
mesa = StudyFactory.create(short_name="MESA", full_name="MESA")
try:
aric = Study.objects.get(short_name="ARIC")
except Study.DoesNotExist:
aric = Study.objects.create(short_name="ARIC", full_name="Atherosclerosis Risk in Communities")

# Create some CDSAs
cdsa_1001 = factories.MemberAgreementFactory.create(
Expand All @@ -51,7 +68,7 @@
signed_agreement__representative_role="Contact PI",
is_primary=True,
signed_agreement__version=v10,
study_site=StudySite.objects.get(short_name="CC"),
study_site=cc,
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1001.signed_agreement.anvil_access_group)

Expand All @@ -62,7 +79,7 @@
signed_agreement__representative_role="Contact PI",
is_primary=True,
signed_agreement__version=v10,
study_site=StudySite.objects.get(short_name="CARDINAL"),
study_site=cardinal,
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1002.signed_agreement.anvil_access_group)

Expand All @@ -73,7 +90,7 @@
signed_agreement__representative_role="Co-PI",
is_primary=False,
signed_agreement__version=v10,
study_site=StudySite.objects.get(short_name="CARDINAL"),
study_site=cardinal,
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1003.signed_agreement.anvil_access_group)

Expand All @@ -84,7 +101,7 @@
signed_agreement__representative_role="Co-I",
is_primary=False,
signed_agreement__version=v11,
study_site=StudySite.objects.get(short_name="CARDINAL"),
study_site=cardinal,
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1004.signed_agreement.anvil_access_group)

Expand All @@ -93,7 +110,7 @@
signed_agreement__representative=User.objects.get(name="Brackie Mitchell"),
signed_agreement__signing_institution="UMaryland",
signed_agreement__representative_role="Study PI",
study=Study.objects.get(short_name="Amish"),
study=amish,
signed_agreement__version=v10,
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1005.signed_agreement.anvil_access_group)
Expand All @@ -103,7 +120,7 @@
signed_agreement__representative=UserFactory.create(name="Robyn"),
signed_agreement__representative_role="DCC PI",
signed_agreement__signing_institution="UW",
study=Study.objects.get(short_name="MESA"),
study=mesa,
signed_agreement__version=v10,
additional_limitations="This data can only be used for testing the app.",
requires_study_review=True,
Expand All @@ -116,7 +133,7 @@
signed_agreement__signing_institution="JHU",
signed_agreement__representative_role="Field Center PI",
is_primary=False,
study=Study.objects.get(short_name="MESA"),
study=mesa,
signed_agreement__version=v10,
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1007.signed_agreement.anvil_access_group)
Expand All @@ -127,7 +144,7 @@
signed_agreement__signing_institution="Lundquist",
signed_agreement__representative_role="Analysis Center PI",
is_primary=False,
study=Study.objects.get(short_name="MESA"),
study=mesa,
signed_agreement__version=v10,
)
GroupGroupMembershipFactory.create(parent_group=cdsa_group, child_group=cdsa_1008.signed_agreement.anvil_access_group)
Expand All @@ -147,52 +164,69 @@


# Add some users to the CDSA groups.
accounts = AccountFactory.create_batch(10, verified=True)
GroupAccountMembershipFactory.create(
group=cdsa_1001.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
)
users = UserFactory.create_batch(12)
cdsa_1001.signed_agreement.accessors.add(users[0])
GroupAccountMembershipFactory.create(
group=cdsa_1001.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
account__user=users[0],
)
# # Do not add as an accessor so we can check auditing.
# cdsa_1001.signed_agreement.accessors.add(users[1])
GroupAccountMembershipFactory.create(
group=cdsa_1001.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
)
account__user=users[1],
)
cdsa_1001.signed_agreement.accessors.add(users[2])
AccountFactory.create(user=users[2])
# # Do not create the GroupAccountMembership so we can check auditing.
# GroupAccountMembershipFactory.create(
# group=cdsa_1001.signed_agreement.anvil_access_group,
# account__user=users[2],
# )
cdsa_1002.signed_agreement.accessors.add(users[3])
GroupAccountMembershipFactory.create(
group=cdsa_1002.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
account__user=users[3],
)
cdsa_1002.signed_agreement.accessors.add(users[4])
GroupAccountMembershipFactory.create(
group=cdsa_1002.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
account__user=users[4],
)
cdsa_1003.signed_agreement.accessors.add(users[5])
GroupAccountMembershipFactory.create(
group=cdsa_1003.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
account__user=users[5],
)
cdsa_1005.signed_agreement.accessors.add(users[6])
GroupAccountMembershipFactory.create(
group=cdsa_1005.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
account__user=users[6],
)
cdsa_1005.signed_agreement.accessors.add(users[7])
GroupAccountMembershipFactory.create(
group=cdsa_1005.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
account__user=users[7],
)
cdsa_1006.signed_agreement.accessors.add(users[8])
GroupAccountMembershipFactory.create(
group=cdsa_1006.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
account__user=users[8],
)
cdsa_1006.signed_agreement.accessors.add(users[9])
GroupAccountMembershipFactory.create(
group=cdsa_1006.signed_agreement.anvil_access_group,
account__user=UserFactory.create(),
account__user=users[9],
)
# Add uploaders.
cdsa_1006.uploaders.add(users[10])
AccountFactory.create(user=users[10])
cdsa_1006.uploaders.add(users[11])

cdsa_workspace_1 = factories.CDSAWorkspaceFactory.create(
workspace__billing_project__name="demo-primed-cdsa",
workspace__name="DEMO_PRIMED_CDSA_MESA_1",
study=Study.objects.get(short_name="MESA"),
study=mesa,
data_use_permission=dup,
)
GroupGroupMembershipFactory.create(
Expand All @@ -205,7 +239,7 @@
cdsa_workspace_2 = factories.CDSAWorkspaceFactory.create(
workspace__billing_project__name="demo-primed-cdsa",
workspace__name="DEMO_PRIMED_CDSA_MESA_2",
study=Study.objects.get(short_name="MESA"),
study=mesa,
data_use_permission=dup,
additional_limitations="Additional limitations for workspace.",
)
Expand All @@ -216,6 +250,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=aric,
data_use_permission=dup,
)
42 changes: 38 additions & 4 deletions add_dbgap_example_data.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
# Temporary script to create some test data.
# Run with: python manage.py shell < add_cdsa_example_data.py

from anvil_consortium_manager.tests.factories import GroupGroupMembershipFactory
from anvil_consortium_manager.tests.factories import (
AccountFactory,
GroupAccountMembershipFactory,
GroupGroupMembershipFactory,
)

from primed.dbgap import models
from primed.dbgap.tests import factories
from primed.primed_anvil.tests.factories import StudyFactory
from primed.users.tests.factories import UserFactory

# 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")
try:
fhs = models.Study.objects.get(short_name="FHS")
except models.Study.DoesNotExist:
fhs = StudyFactory.create(short_name="FHS", full_name="Framingham Heart Study")
try:
mesa = models.Study.objects.get(short_name="MESA")
except models.Study.DoesNotExist:
mesa = StudyFactory.create(short_name="MESA", full_name="Multi-Ethnic Study of Atherosclerosis")
try:
aric = models.Study.objects.get(short_name="ARIC")
except models.Study.DoesNotExist:
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])
Expand Down Expand Up @@ -124,3 +137,24 @@
parent_group=workspace_fhs_1.workspace.authorization_domains.first(),
child_group=dbgap_application_1.anvil_access_group,
)

# Add the PI to the access group for the first application.
GroupAccountMembershipFactory.create(
group=dbgap_application_1.anvil_access_group,
account__user=dbgap_application_1.principal_investigator,
)
# Add some collaborators for the first application.
users = UserFactory.create_batch(3)
dbgap_application_1.collaborators.add(users[0])
GroupAccountMembershipFactory.create(
group=dbgap_application_1.anvil_access_group,
account__user=users[0],
)
# # Do not add as an collaborator so we can check auditing.
# dbgap_application_1.collaborators.add(users[1])
GroupAccountMembershipFactory.create(
group=dbgap_application_1.anvil_access_group,
account__user=users[1],
)
dbgap_application_1.collaborators.add(users[2])
AccountFactory.create(user=users[2], verified=True)
Loading

0 comments on commit e5db17c

Please sign in to comment.