nci-cidc-api-modules 1.2.11__tar.gz → 1.2.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of nci-cidc-api-modules might be problematic. Click here for more details.
- {nci_cidc_api_modules-1.2.11/nci_cidc_api_modules.egg-info → nci_cidc_api_modules-1.2.13}/PKG-INFO +1 -1
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/config/settings.py +4 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/shared/emails.py +32 -2
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/shared/file_handling.py +15 -5
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13/nci_cidc_api_modules.egg-info}/PKG-INFO +1 -1
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/LICENSE +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/MANIFEST.in +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/README.md +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/config/__init__.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/config/db.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/config/logging.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/config/secrets.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/models/__init__.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/models/files/__init__.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/models/files/details.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/models/files/facets.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/models/migrations.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/models/models.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/models/schemas.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/shared/__init__.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/shared/auth.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/shared/gcloud_client.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/shared/jose.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/shared/rest_utils.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/nci_cidc_api_modules.egg-info/SOURCES.txt +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/nci_cidc_api_modules.egg-info/dependency_links.txt +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/nci_cidc_api_modules.egg-info/not-zip-safe +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/nci_cidc_api_modules.egg-info/requires.txt +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/nci_cidc_api_modules.egg-info/top_level.txt +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/pyproject.toml +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/requirements.modules.txt +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/setup.cfg +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/setup.py +0 -0
- {nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/tests/test_api.py +0 -0
|
@@ -108,5 +108,9 @@ else:
|
|
|
108
108
|
IS_EMAIL_ON = environ.get("IS_EMAIL_ON")
|
|
109
109
|
|
|
110
110
|
|
|
111
|
+
# notification emails
|
|
112
|
+
CIDC_CLINICAL_DATA_EMAIL = environ.get("CIDC_CLINICAL_DATA_EMAIL")
|
|
113
|
+
CIDC_ADMIN_EMAIL = environ.get("CIDC_ADMIN_EMAIL")
|
|
114
|
+
|
|
111
115
|
# Accumulate all constants defined in this file in a single dictionary
|
|
112
116
|
SETTINGS = {k: v for k, v in globals().items() if k.isupper()}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"""Template functions for CIDC email bodies."""
|
|
2
2
|
|
|
3
3
|
import html
|
|
4
|
+
import pathlib
|
|
4
5
|
from functools import wraps
|
|
5
6
|
from typing import List
|
|
6
7
|
|
|
7
8
|
from . import gcloud_client
|
|
8
|
-
from ..config.settings import ENV
|
|
9
|
+
from ..config.settings import ENV, ALLOWED_CLIENT_URL, CIDC_CLINICAL_DATA_EMAIL, CIDC_ADMIN_EMAIL
|
|
9
10
|
|
|
10
11
|
# emails this list for
|
|
11
12
|
# - new user registration,
|
|
@@ -44,7 +45,7 @@ def confirm_account_approval(user) -> dict:
|
|
|
44
45
|
html_content = f"""
|
|
45
46
|
<p>Hello {user.first_n},</p>
|
|
46
47
|
<p>
|
|
47
|
-
Your CIMAC-CIDC Portal account has been approved!
|
|
48
|
+
Your CIMAC-CIDC Portal account has been approved!
|
|
48
49
|
To begin browsing and downloading data, visit https://cidc.nci.nih.gov.
|
|
49
50
|
</p>
|
|
50
51
|
<p>
|
|
@@ -150,3 +151,32 @@ def notify_mailing_list(subject: str, html_content: str) -> dict:
|
|
|
150
151
|
"html_content": html_content,
|
|
151
152
|
}
|
|
152
153
|
return email
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
with open(pathlib.Path(__file__).parent.joinpath("email_layout.html"), encoding="utf-8") as file:
|
|
157
|
+
EMAIL_LAYOUT = file.read()
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
@sendable
|
|
161
|
+
def new_validation_review(job: dict) -> dict:
|
|
162
|
+
# these two emails are set only in prod env file
|
|
163
|
+
if CIDC_CLINICAL_DATA_EMAIL and CIDC_ADMIN_EMAIL:
|
|
164
|
+
to_emails = [CIDC_CLINICAL_DATA_EMAIL, CIDC_ADMIN_EMAIL]
|
|
165
|
+
else:
|
|
166
|
+
to_emails = CIDC_MAILING_LIST
|
|
167
|
+
|
|
168
|
+
subject = f"Trial {job.trial_id} ({job.version}) Ready for Validation Review"
|
|
169
|
+
html_heading = "Clinical Data Upload Notification"
|
|
170
|
+
job_url = f"{ALLOWED_CLIENT_URL}/upload-clinical-data/{job.id}"
|
|
171
|
+
|
|
172
|
+
html_content = f"""
|
|
173
|
+
<b>Ready for Validation Review:</b><br>
|
|
174
|
+
<b><a class="blue-link" href={job_url}>Trial {job.trial_id} version {job.version} (Job ID {job.id})</a></b>
|
|
175
|
+
Please follow the link to access the trial's clinical data submission page.
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
"to_emails": to_emails,
|
|
180
|
+
"subject": subject,
|
|
181
|
+
"html_content": EMAIL_LAYOUT.replace("$HEADING", html_heading).replace("$CONTENT", html_content),
|
|
182
|
+
}
|
{nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/shared/file_handling.py
RENAMED
|
@@ -8,22 +8,31 @@ from ..config.settings import GOOGLE_CLINICAL_DATA_BUCKET
|
|
|
8
8
|
from ..models import PreprocessedFiles
|
|
9
9
|
from ..shared.auth import get_current_user
|
|
10
10
|
from ..shared.gcloud_client import upload_file_to_gcs, move_gcs_file
|
|
11
|
+
from sqlalchemy.orm.session import Session
|
|
11
12
|
|
|
12
13
|
logger = get_logger(__name__)
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
def set_current_file(
|
|
16
|
+
def set_current_file(
|
|
17
|
+
file: FileStorage, file_category: str, gcs_folder: str, session: Session, uploader_email: str, job_id: int = None
|
|
18
|
+
) -> PreprocessedFiles:
|
|
16
19
|
"""
|
|
17
20
|
Archives any existing 'current' files for the given category and job,
|
|
18
21
|
then uploads the new file as the latest 'current' version.
|
|
19
22
|
"""
|
|
20
|
-
latest_version = PreprocessedFiles.archive_current_files(file_category, job_id=job_id)
|
|
21
|
-
latest_file = create_file(file, gcs_folder, file_category, job_id, latest_version + 1)
|
|
23
|
+
latest_version = PreprocessedFiles.archive_current_files(file_category, job_id=job_id, session=session)
|
|
24
|
+
latest_file = create_file(file, gcs_folder, file_category, session, uploader_email, job_id, latest_version + 1)
|
|
22
25
|
return latest_file
|
|
23
26
|
|
|
24
27
|
|
|
25
28
|
def create_file(
|
|
26
|
-
file: FileStorage,
|
|
29
|
+
file: FileStorage,
|
|
30
|
+
gcs_folder: str,
|
|
31
|
+
file_category: str,
|
|
32
|
+
session: Session,
|
|
33
|
+
uploader_email: str,
|
|
34
|
+
job_id: int = None,
|
|
35
|
+
version: int = None,
|
|
27
36
|
) -> PreprocessedFiles:
|
|
28
37
|
"""Upload file to GCS and create corresponding metadata record in the database."""
|
|
29
38
|
status = "pending" if gcs_folder.endswith("pending/") else "current"
|
|
@@ -36,10 +45,11 @@ def create_file(
|
|
|
36
45
|
file_name=file.filename,
|
|
37
46
|
object_url=gcs_file_path,
|
|
38
47
|
file_category=file_category,
|
|
39
|
-
uploader_email=
|
|
48
|
+
uploader_email=uploader_email,
|
|
40
49
|
status=status,
|
|
41
50
|
job_id=job_id,
|
|
42
51
|
version=version,
|
|
52
|
+
session=session,
|
|
43
53
|
)
|
|
44
54
|
return file
|
|
45
55
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/models/files/__init__.py
RENAMED
|
File without changes
|
{nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/models/files/details.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nci_cidc_api_modules-1.2.11 → nci_cidc_api_modules-1.2.13}/cidc_api/shared/gcloud_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|