-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start adding study collections, including some test artifacts * Deal with study handle object versus string * Version bump * Add script to deal with collection tags * Correct identification of database record * Version bumps * Allow uploading of preloaded images to save dev time * Update pull policy to allow prebuilt remote data images * Modify promotion mechanism to a whitelist * Modify promotion mechanism to a whitelist, including api study name * Add check for table existence * Clean up cli for new publish/unpublish feature * update changelog
- Loading branch information
1 parent
8318ce3
commit d1d4ef8
Showing
40 changed files
with
855 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[general] | ||
db_config_file_path = build/db/.spt_db.config.local | ||
study_name = Melanoma intralesional IL2 collection: abc-123 | ||
|
||
[upload-importances] | ||
plugin_used = cg-gnn | ||
datetime_of_run = 2023-10-02 10:46 AM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[general] | ||
db_config_file = build/db/.spt_db.config.local | ||
executor = local | ||
|
||
[tabular import] | ||
input_path = test/test_data/adi_preprocessed_tables/datasetYYY | ||
|
||
[database visitor] | ||
study_name = Melanoma intralesional IL2 collection: abc-123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
"""API service""" | ||
__version__ = '0.14.0' | ||
__version__ = '0.23.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
"""Database-related SPT functionality.""" | ||
__version__ = '0.13.0' | ||
__version__ = '0.23.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"""Publish/promote a dataset collection from private to public.""" | ||
|
||
from typing import cast | ||
|
||
from attr import define | ||
|
||
from spatialprofilingtoolbox.db.database_connection import DBCursor | ||
from spatialprofilingtoolbox.db.study_tokens import StudyCollectionNaming | ||
from spatialprofilingtoolbox.standalone_utilities.log_formats import colorized_logger | ||
|
||
logger = colorized_logger(__name__) | ||
|
||
@define | ||
class PublisherPromoter: | ||
database_config_file: str | ||
collection: str | None = None | ||
|
||
def promote(self, collection: str) -> None: | ||
self.collection = collection | ||
self._check_is_collection_nonempty() | ||
self._whitelist_collection() | ||
|
||
def demote(self, collection: str) -> None: | ||
self.collection = collection | ||
self._check_is_collection_nonempty() | ||
self._unwhitelist_collection() | ||
|
||
def _check_is_collection_nonempty(self) -> None: | ||
def is_in_collection(study: str) -> bool: | ||
_, tag = StudyCollectionNaming.strip_token(study) | ||
return tag == self._get_collection() | ||
file = self.database_config_file | ||
with DBCursor(database_config_file=file, study=None) as cursor: | ||
update = f'SELECT study FROM study_lookup ;' | ||
cursor.execute(update) | ||
members = tuple(filter(is_in_collection, map(lambda row: row[0], cursor.fetchall()))) | ||
if len(members) == 0: | ||
message = f'No studies are tagged with collection label "{self._get_collection()}".' | ||
logger.warn(message) | ||
|
||
def _whitelist_collection(self) -> None: | ||
file = self.database_config_file | ||
with DBCursor(database_config_file=file, study=None) as cursor: | ||
collection = self._get_collection() | ||
create = f'CREATE TABLE IF NOT EXISTS collection_whitelist ( collection VARCHAR(512) );' | ||
insert = f'INSERT INTO collection_whitelist (collection) VALUES ( %s ) ;' | ||
logger.debug(create) | ||
cursor.execute(create) | ||
logger.debug(insert % f"'{collection}'") | ||
cursor.execute(insert, (collection,)) | ||
logger.info(f'Added "{collection}" to public-indicating whitelist.') | ||
|
||
def _unwhitelist_collection(self) -> None: | ||
file = self.database_config_file | ||
with DBCursor(database_config_file=file, study=None) as cursor: | ||
collection = self._get_collection() | ||
remove = f'DELETE FROM collection_whitelist WHERE collection=%s ;' | ||
logger.debug(remove % f"'{collection}'") | ||
cursor.execute(remove, (collection,)) | ||
logger.info(f'Removed "{collection}" from public-indicating whitelist.') | ||
|
||
def _get_collection(self) -> str: | ||
return cast(str, self.collection) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.