diff --git a/pydatalab/pydatalab/blocks/__init__.py b/pydatalab/pydatalab/blocks/__init__.py index a35bea310..6d5be31b0 100644 --- a/pydatalab/pydatalab/blocks/__init__.py +++ b/pydatalab/pydatalab/blocks/__init__.py @@ -1,4 +1,4 @@ -from typing import Dict, Sequence, Type +from typing import TYPE_CHECKING, Dict, Sequence, Type # These app imports will be replaced by dynamic plugins in a future version from pydatalab.apps.chat.blocks import ChatBlock @@ -8,17 +8,13 @@ from pydatalab.apps.raman import RamanBlock from pydatalab.apps.tga import MassSpecBlock from pydatalab.apps.xrd import XRDBlock -from pydatalab.blocks.base import ( - DataBlock, -) -from pydatalab.blocks.common import ( - CommentBlock, - MediaBlock, - NotSupportedBlock, -) -BLOCKS: Sequence[Type[DataBlock]] = ( - DataBlock, +if TYPE_CHECKING: + from pydatalab.blocks.base import DataBlock + +from pydatalab.blocks.common import CommentBlock, MediaBlock, NotSupportedBlock + +BLOCKS: Sequence[Type["DataBlock"]] = ( CommentBlock, MediaBlock, XRDBlock, @@ -31,11 +27,9 @@ EISBlock, ) -BLOCK_TYPES: Dict[str, Type[DataBlock]] = {block.blocktype: block for block in BLOCKS} -BLOCK_TYPES["test"] = DataBlock +BLOCK_TYPES: Dict[str, Type["DataBlock"]] = {block.blocktype: block for block in BLOCKS} __all__ = ( - "DataBlock", "CommentBlock", "MediaBlock", "XRDBlock", diff --git a/pydatalab/pydatalab/file_utils.py b/pydatalab/pydatalab/file_utils.py index fce2cf4e1..80c9c8e1d 100644 --- a/pydatalab/pydatalab/file_utils.py +++ b/pydatalab/pydatalab/file_utils.py @@ -15,7 +15,7 @@ from pydatalab.models import File from pydatalab.models.utils import PyObjectId from pydatalab.mongo import flask_mongo -from pydatalab.routes.utils import get_default_permissions +from pydatalab.permissions import get_default_permissions FILE_DIRECTORY = CONFIG.FILE_DIRECTORY DIRECTORIES_DICT = {fs.name: fs for fs in CONFIG.REMOTE_FILESYSTEMS} @@ -302,7 +302,7 @@ def save_uploaded_file( last_modified should be an isodate format. if last_modified is None, the current time will be inserted """ - from pydatalab.routes.utils import get_default_permissions + from pydatalab.permissions import get_default_permissions sample_collection = flask_mongo.db.items file_collection = flask_mongo.db.files @@ -388,7 +388,7 @@ def save_uploaded_file( def add_file_from_remote_directory(file_entry, item_id, block_ids=None): - from pydatalab.routes.utils import get_default_permissions + from pydatalab.permissions import get_default_permissions file_collection = flask_mongo.db.files sample_collection = flask_mongo.db.items @@ -504,7 +504,7 @@ def remove_file_from_sample(item_id: Union[str, ObjectId], file_id: Union[str, O file_id: The database ID of the file to remove from the item. """ - from pydatalab.routes.utils import get_default_permissions + from pydatalab.permissions import get_default_permissions item_id, file_id = ObjectId(item_id), ObjectId(file_id) sample_collection = flask_mongo.db.items diff --git a/pydatalab/pydatalab/routes/utils.py b/pydatalab/pydatalab/permissions.py similarity index 100% rename from pydatalab/pydatalab/routes/utils.py rename to pydatalab/pydatalab/permissions.py diff --git a/pydatalab/pydatalab/routes/v0_1/blocks.py b/pydatalab/pydatalab/routes/v0_1/blocks.py index 511a90624..d9a005c85 100644 --- a/pydatalab/pydatalab/routes/v0_1/blocks.py +++ b/pydatalab/pydatalab/routes/v0_1/blocks.py @@ -2,10 +2,11 @@ from flask import jsonify, request -from pydatalab.blocks import BLOCK_TYPES, DataBlock +from pydatalab.blocks import BLOCK_TYPES +from pydatalab.blocks.base import DataBlock from pydatalab.logger import LOGGER from pydatalab.mongo import flask_mongo -from pydatalab.routes.utils import get_default_permissions +from pydatalab.permissions import get_default_permissions def add_data_block(): diff --git a/pydatalab/pydatalab/routes/v0_1/collections.py b/pydatalab/pydatalab/routes/v0_1/collections.py index 676070803..09c205d3e 100644 --- a/pydatalab/pydatalab/routes/v0_1/collections.py +++ b/pydatalab/pydatalab/routes/v0_1/collections.py @@ -10,7 +10,7 @@ from pydatalab.logger import logged_route from pydatalab.models.collections import Collection from pydatalab.mongo import flask_mongo -from pydatalab.routes.utils import get_default_permissions +from pydatalab.permissions import get_default_permissions from pydatalab.routes.v0_1.items import creators_lookup, get_samples_summary collection = Blueprint("collections", __name__) diff --git a/pydatalab/pydatalab/routes/v0_1/files.py b/pydatalab/pydatalab/routes/v0_1/files.py index 86731cd1d..5b0080398 100644 --- a/pydatalab/pydatalab/routes/v0_1/files.py +++ b/pydatalab/pydatalab/routes/v0_1/files.py @@ -11,7 +11,7 @@ import pydatalab.mongo from pydatalab import file_utils from pydatalab.config import CONFIG -from pydatalab.routes.utils import get_default_permissions +from pydatalab.permissions import get_default_permissions def get_file(file_id: str, filename: str): diff --git a/pydatalab/pydatalab/routes/v0_1/graphs.py b/pydatalab/pydatalab/routes/v0_1/graphs.py index f5ca0eb96..5c2acb032 100644 --- a/pydatalab/pydatalab/routes/v0_1/graphs.py +++ b/pydatalab/pydatalab/routes/v0_1/graphs.py @@ -3,7 +3,7 @@ from flask import jsonify, request from pydatalab.mongo import flask_mongo -from pydatalab.routes.utils import get_default_permissions +from pydatalab.permissions import get_default_permissions def get_graph_cy_format(item_id: Optional[str] = None, collection_id: Optional[str] = None): diff --git a/pydatalab/pydatalab/routes/v0_1/items.py b/pydatalab/pydatalab/routes/v0_1/items.py index 57f298a31..fd9e13ee2 100644 --- a/pydatalab/pydatalab/routes/v0_1/items.py +++ b/pydatalab/pydatalab/routes/v0_1/items.py @@ -16,7 +16,7 @@ from pydatalab.models.relationships import RelationshipType from pydatalab.models.utils import generate_unique_refcode from pydatalab.mongo import flask_mongo -from pydatalab.routes.utils import get_default_permissions +from pydatalab.permissions import get_default_permissions def reserialize_blocks(display_order: List[str], blocks_obj: Dict[str, Dict]) -> Dict[str, Dict]: