File size: 2,131 Bytes
5301c48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Move storage-related functions here
from typing import Dict, Any
from starfish.data_factory.storage.models import Project
from starfish.data_factory.constants import (
    LOCAL_STORAGE_URI,
)
from starfish.data_factory.storage.local.local_storage import create_local_storage
from starfish.common.logger import get_logger

logger = get_logger(__name__)
# Create storage instance
storage = create_local_storage(LOCAL_STORAGE_URI)


async def setup_storage():
    """Setup storage - to be called during app startup"""
    await storage.setup()
    logger.info("Storage setup completed")


async def close_storage():
    """Close storage - to be called during app shutdown"""
    await storage.close()
    logger.info("Storage closed")


async def save_project(project: Project):
    # Implementation here
    await storage.save_project(project)


async def get_project(project_id: str):
    # Implementation here
    return await storage.get_project(project_id)


async def list_projects():
    # Implementation here
    return await storage.list_projects()


async def delete_project(project_id: str):
    # Implementation here
    await storage.delete_project(project_id)


async def save_dataset(project_name: str, dataset_name: str, dataset_data: Dict[str, Any]):
    # Implementation here
    await storage.save_dataset(project_name, dataset_name, dataset_data)


async def get_dataset(project_name: str, dataset_name: str):
    # Implementation here
    return await storage.get_dataset(project_name, dataset_name)


async def list_datasets(project_name: str):
    # Implementation here
    return await storage.list_datasets(project_name)


async def list_datasets_from_storage(project_id: str, dataset_type: str):
    # Implementation here
    if dataset_type == "factory":
        return []
    elif dataset_type == "template":
        return await storage.list_datasets(project_id)
    else:
        raise ValueError(f"Invalid dataset type: {dataset_type}")


async def get_dataset_from_storage(project_id: str, dataset_name: str):
    # Implementation here
    return await storage.get_dataset(project_id, dataset_name)