nci-cidc-api-modules 1.1.39__py3-none-any.whl → 1.1.40__py3-none-any.whl
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.
- cidc_api/config/db.py +34 -5
- cidc_api/models/models.py +3 -1
- {nci_cidc_api_modules-1.1.39.dist-info → nci_cidc_api_modules-1.1.40.dist-info}/METADATA +2 -2
- {nci_cidc_api_modules-1.1.39.dist-info → nci_cidc_api_modules-1.1.40.dist-info}/RECORD +7 -7
- {nci_cidc_api_modules-1.1.39.dist-info → nci_cidc_api_modules-1.1.40.dist-info}/WHEEL +0 -0
- {nci_cidc_api_modules-1.1.39.dist-info → nci_cidc_api_modules-1.1.40.dist-info}/licenses/LICENSE +0 -0
- {nci_cidc_api_modules-1.1.39.dist-info → nci_cidc_api_modules-1.1.40.dist-info}/top_level.txt +0 -0
cidc_api/config/db.py
CHANGED
@@ -45,7 +45,34 @@ def get_sqlalchemy_database_uri(testing: bool = False) -> str:
|
|
45
45
|
# Connect to the test database
|
46
46
|
db_uri = environ.get("TEST_POSTGRES_URI", "fake-conn-string")
|
47
47
|
elif not db_uri:
|
48
|
-
|
48
|
+
# TODO: figure out why IAM authentication causes an issue with the huge filter query
|
49
|
+
# db_uri = f"postgresql+pg8000://{environ.get('CLOUD_SQL_DB_USER')}:xxx@/{environ.get('CLOUD_SQL_DB_NAME')}"
|
50
|
+
|
51
|
+
secrets = get_secrets_manager(testing)
|
52
|
+
|
53
|
+
# If POSTGRES_URI env variable is not set,
|
54
|
+
# we're connecting to a Cloud SQL instance.
|
55
|
+
|
56
|
+
config: dict = {
|
57
|
+
"drivername": "postgresql",
|
58
|
+
"username": environ.get("CLOUD_SQL_DB_USER"),
|
59
|
+
"password": secrets.get(environ.get("CLOUD_SQL_DB_PASS_ID")),
|
60
|
+
"database": environ.get("CLOUD_SQL_DB_NAME"),
|
61
|
+
}
|
62
|
+
|
63
|
+
if environ.get("CLOUD_SQL_INSTANCE_NAME"):
|
64
|
+
socket_dir = environ.get("CLOUD_SQL_SOCKET_DIR", "/cloudsql/")
|
65
|
+
|
66
|
+
# If CLOUD_SQL_INSTANCE_NAME is defined, we're connecting
|
67
|
+
# via a unix socket from inside App Engine.
|
68
|
+
config["query"] = {"host": f'{socket_dir}{environ.get("CLOUD_SQL_INSTANCE_NAME")}'}
|
69
|
+
else:
|
70
|
+
raise RuntimeError(
|
71
|
+
"Either POSTGRES_URI or CLOUD_SQL_INSTANCE_NAME must be defined to connect " + "to a database."
|
72
|
+
)
|
73
|
+
|
74
|
+
db_uri = str(URL.create(**config).render_as_string(hide_password=False))
|
75
|
+
|
49
76
|
assert db_uri
|
50
77
|
|
51
78
|
return db_uri
|
@@ -53,7 +80,9 @@ def get_sqlalchemy_database_uri(testing: bool = False) -> str:
|
|
53
80
|
|
54
81
|
# Use SQLALCHEMY_ENGINE_OPTIONS to connect to the cloud but use uri for local db
|
55
82
|
def cloud_connector(testing: bool = False):
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
83
|
+
return {}
|
84
|
+
# TODO: figure out IAM authentication
|
85
|
+
# if not testing and not environ.get("POSTGRES_URI"):
|
86
|
+
# return {"creator": getconn}
|
87
|
+
# else:
|
88
|
+
# return {}
|
cidc_api/models/models.py
CHANGED
@@ -3463,13 +3463,15 @@ class IngestionJobs(CommonColumns):
|
|
3463
3463
|
@with_default_session
|
3464
3464
|
def atomic_set_job_as_pending(cls, job_id: int, session: Session) -> Boolean:
|
3465
3465
|
# Preventing rare race condition where multiple people try and submit a job for validation
|
3466
|
-
|
3466
|
+
result = bool(
|
3467
3467
|
session.execute(
|
3468
3468
|
update(IngestionJobs)
|
3469
3469
|
.where(and_(IngestionJobs.id == job_id, IngestionJobs.pending == False))
|
3470
3470
|
.values(pending=True)
|
3471
3471
|
).rowcount
|
3472
3472
|
)
|
3473
|
+
session.commit()
|
3474
|
+
return result
|
3473
3475
|
|
3474
3476
|
@classmethod
|
3475
3477
|
@with_default_session
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nci_cidc_api_modules
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.40
|
4
4
|
Summary: SQLAlchemy data models and configuration tools used in the NCI CIDC API
|
5
5
|
Home-page: https://github.com/NCI-CIDC/cidc-api-gae
|
6
6
|
License: MIT license
|
@@ -29,7 +29,7 @@ Requires-Dist: requests==2.32.4
|
|
29
29
|
Requires-Dist: jinja2==3.1.6
|
30
30
|
Requires-Dist: certifi==2024.7.4
|
31
31
|
Requires-Dist: cloud-sql-python-connector[pg8000]==1.18.3
|
32
|
-
Requires-Dist: nci-cidc-schemas==0.27.
|
32
|
+
Requires-Dist: nci-cidc-schemas==0.27.28
|
33
33
|
Dynamic: description
|
34
34
|
Dynamic: description-content-type
|
35
35
|
Dynamic: home-page
|
@@ -1,11 +1,11 @@
|
|
1
1
|
cidc_api/config/__init__.py,sha256=5mX8GAPxUKV84iS-aGOoE-4m68LsOCGCDptXNdlgvj0,148
|
2
|
-
cidc_api/config/db.py,sha256=
|
2
|
+
cidc_api/config/db.py,sha256=kbCemCDYv_zyczw-V7H2JvLCa_XeEcvXkzvF28FxADw,2862
|
3
3
|
cidc_api/config/logging.py,sha256=abhVYtn8lfhIt0tyV2WHFgSmp_s2eeJh7kodB6LH4J0,1149
|
4
4
|
cidc_api/config/secrets.py,sha256=jRFj7W43pWuPf9DZQLCKF7WPXf5cUv-BAaS3ASqhV_Q,1481
|
5
5
|
cidc_api/config/settings.py,sha256=NsJbqW6Vqcz2f79xcAbk4th5tHne_I-RPCbKq_3hpz0,4427
|
6
6
|
cidc_api/models/__init__.py,sha256=bl445G8Zic9YbhZ8ZBni07wtBMhLJRMBA-JqjLxx2bw,66
|
7
7
|
cidc_api/models/migrations.py,sha256=gp9vtkYbA9FFy2s-7woelAmsvQbJ41LO2_DY-YkFIrQ,11464
|
8
|
-
cidc_api/models/models.py,sha256
|
8
|
+
cidc_api/models/models.py,sha256=eRZrUcQYIe_V5hMwD3ONc175vPQpUTe_KPcmGdYexJc,142944
|
9
9
|
cidc_api/models/schemas.py,sha256=6IE2dJoEMcMbi0Vr1V3cYKnPKU0hv9vRKBixOZHe88s,2766
|
10
10
|
cidc_api/models/files/__init__.py,sha256=8BMTnUSHzUbz0lBeEQY6NvApxDD3GMWMduoVMos2g4Y,213
|
11
11
|
cidc_api/models/files/details.py,sha256=sZkGM7iEV4-J6IDQCdiMV6KBDLbPxCOqUMaU3aY9rX8,65153
|
@@ -17,8 +17,8 @@ cidc_api/shared/file_handling.py,sha256=l4wiRkVJLL7QbCoODsLx-uki6Km8QoMmUlRVnUV9
|
|
17
17
|
cidc_api/shared/gcloud_client.py,sha256=cNtzCRsD_StBQRAzWJ8BimW-ecEGOqywvlM7kip8CrE,36681
|
18
18
|
cidc_api/shared/jose.py,sha256=-qzGzEDAlokEp9E7WtBtQkXyyfPWTYXlwYpCqVJWmqM,1830
|
19
19
|
cidc_api/shared/rest_utils.py,sha256=RwR30WOUAYCxL7V-i2totEyeriG30GbBDvBcpLXhM9w,6594
|
20
|
-
nci_cidc_api_modules-1.1.
|
21
|
-
nci_cidc_api_modules-1.1.
|
22
|
-
nci_cidc_api_modules-1.1.
|
23
|
-
nci_cidc_api_modules-1.1.
|
24
|
-
nci_cidc_api_modules-1.1.
|
20
|
+
nci_cidc_api_modules-1.1.40.dist-info/licenses/LICENSE,sha256=pNYWVTHaYonnmJyplmeAp7tQAjosmDpAWjb34jjv7Xs,1102
|
21
|
+
nci_cidc_api_modules-1.1.40.dist-info/METADATA,sha256=IZwg1tt0j0d6j8ve8d3yYrfck4Hnp_GKo2By-9bb0vM,39967
|
22
|
+
nci_cidc_api_modules-1.1.40.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
nci_cidc_api_modules-1.1.40.dist-info/top_level.txt,sha256=rNiRzL0lJGi5Q9tY9uSoMdTbJ-7u5c_D2E86KA94yRA,9
|
24
|
+
nci_cidc_api_modules-1.1.40.dist-info/RECORD,,
|
File without changes
|
{nci_cidc_api_modules-1.1.39.dist-info → nci_cidc_api_modules-1.1.40.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{nci_cidc_api_modules-1.1.39.dist-info → nci_cidc_api_modules-1.1.40.dist-info}/top_level.txt
RENAMED
File without changes
|