cdiam-cli 0.1.0__tar.gz → 0.1.2__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.
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/PKG-INFO +4 -11
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/README.md +3 -3
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/__main__.py +1 -2
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/api/api_action.py +3 -11
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/api/download.py +1 -2
- cdiam_cli-0.1.2/cdiam_cli/command/__init__.py +2 -0
- cdiam_cli-0.1.2/cdiam_cli/command/data.py +33 -0
- cdiam_cli-0.1.2/cdiam_cli/command/project.py +29 -0
- cdiam_cli-0.1.2/cdiam_cli/main.py +22 -0
- cdiam_cli-0.1.2/cdiam_cli/schemas/analysis.py +60 -0
- cdiam_cli-0.1.2/cdiam_cli/schemas/base.py +28 -0
- cdiam_cli-0.1.2/cdiam_cli/schemas/project.py +36 -0
- cdiam_cli-0.1.2/cdiam_cli/schemas/schemas.py +36 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/pyproject.toml +2 -8
- cdiam_cli-0.1.0/cdiam_cli/main.py +0 -15
- cdiam_cli-0.1.0/cdiam_cli/schemas/schemas.py +0 -213
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/LICENSE.md +0 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/__init__.py +0 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/api/__init__.py +0 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/api/settings.py +0 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/api/utils.py +0 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/helper/__init__.py +0 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/helper/curl_helper.py +0 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/helper/json_helper.py +0 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/helper/yaml_helper.py +0 -0
- {cdiam_cli-0.1.0 → cdiam_cli-0.1.2}/cdiam_cli/schemas/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cdiam-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary:
|
|
5
5
|
Author: tungtp99
|
|
6
6
|
Author-email: tungtp181199@gmail.com
|
|
@@ -13,15 +13,8 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
13
13
|
Requires-Dist: click (>=8.1.7,<9.0.0)
|
|
14
14
|
Requires-Dist: datetime (>=5.5,<6.0)
|
|
15
15
|
Requires-Dist: idna (==3.4)
|
|
16
|
-
Requires-Dist: numpy (>=1.24.0,<2.0.0)
|
|
17
|
-
Requires-Dist: pandas (>=2.1.0,<3.0.0)
|
|
18
16
|
Requires-Dist: pydantic (==1.10.2)
|
|
19
|
-
Requires-Dist: pymysql (==1.0.2)
|
|
20
17
|
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
21
|
-
Requires-Dist: sqlalchemy (==1.4.41)
|
|
22
|
-
Requires-Dist: sqlalchemy2-stubs (==0.0.2a27)
|
|
23
|
-
Requires-Dist: sqlmodel (==0.0.8)
|
|
24
|
-
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
|
|
25
18
|
Requires-Dist: typing-extensions (==4.3.0)
|
|
26
19
|
Description-Content-Type: text/markdown
|
|
27
20
|
|
|
@@ -41,12 +34,12 @@ To get started with this project, follow these steps:
|
|
|
41
34
|
Run `pip install cdiam-cli`
|
|
42
35
|
|
|
43
36
|
### View CLI command
|
|
44
|
-
Run `
|
|
37
|
+
Run `cdiam-cli --help`
|
|
45
38
|
|
|
46
39
|
## Features
|
|
47
40
|
|
|
48
|
-
- Save token: `
|
|
49
|
-
- Call API: `
|
|
41
|
+
- Save token: `cdiam-cli save-token` must provide server endpoint E.g. https://c-diam.com/api and TOKEN get from CDIAM APP
|
|
42
|
+
- Call API: `cdiam-cli call-api <PATH_TO_YAML_OR_JSON_PARAMS>` more detail about params schemas at `<SERVER_ENPOINT>/schemas/docs` E.g. https://c-diam.com/api/schemas/docs
|
|
50
43
|
|
|
51
44
|
|
|
52
45
|
|
|
@@ -14,12 +14,12 @@ To get started with this project, follow these steps:
|
|
|
14
14
|
Run `pip install cdiam-cli`
|
|
15
15
|
|
|
16
16
|
### View CLI command
|
|
17
|
-
Run `
|
|
17
|
+
Run `cdiam-cli --help`
|
|
18
18
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
21
|
-
- Save token: `
|
|
22
|
-
- Call API: `
|
|
21
|
+
- Save token: `cdiam-cli save-token` must provide server endpoint E.g. https://c-diam.com/api and TOKEN get from CDIAM APP
|
|
22
|
+
- Call API: `cdiam-cli call-api <PATH_TO_YAML_OR_JSON_PARAMS>` more detail about params schemas at `<SERVER_ENPOINT>/schemas/docs` E.g. https://c-diam.com/api/schemas/docs
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
@@ -4,9 +4,8 @@ from cdiam_cli.helper import yaml_helper, curl_helper
|
|
|
4
4
|
import subprocess
|
|
5
5
|
from typing import Union, Callable, Any, Dict, overload, Literal
|
|
6
6
|
from .settings import read_api_endpoint, read_api_token
|
|
7
|
-
from cdiam_cli.schemas import AnalysisResult
|
|
8
7
|
from cdiam_cli.schemas import ParamsRequestGetTaskStatus
|
|
9
|
-
from cdiam_cli.schemas import AnalysisResultRead
|
|
8
|
+
from cdiam_cli.schemas.analysis import AnalysisResultRead, AnalysisResult
|
|
10
9
|
from time import sleep
|
|
11
10
|
|
|
12
11
|
|
|
@@ -120,12 +119,5 @@ def call_api(params: str):
|
|
|
120
119
|
Exception: If the API call fails.
|
|
121
120
|
"""
|
|
122
121
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if return_code == 0:
|
|
127
|
-
click.echo(process.stdout.decode())
|
|
128
|
-
return process.stdout.decode()
|
|
129
|
-
else:
|
|
130
|
-
click.echo(process.stdout.decode())
|
|
131
|
-
raise Exception(process.stderr.decode())
|
|
122
|
+
data = run(params)
|
|
123
|
+
print(json.dumps(data, indent=4, sort_keys=True))
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import click
|
|
2
2
|
import requests
|
|
3
|
-
import pandas as pd
|
|
4
3
|
from urllib.request import urlopen
|
|
5
4
|
from .settings import read_api_endpoint, read_api_token
|
|
6
5
|
|
|
@@ -8,7 +7,7 @@ from .settings import read_api_endpoint, read_api_token
|
|
|
8
7
|
@click.command()
|
|
9
8
|
@click.argument("object_id", type=str)
|
|
10
9
|
def download_data(object_id: str):
|
|
11
|
-
"""This api download data of given
|
|
10
|
+
"""This api download data of given object_id"""
|
|
12
11
|
res = requests.get(
|
|
13
12
|
f"{read_api_endpoint()}/data/data/download-file/{object_id}",
|
|
14
13
|
cookies={"cdiam_session_token": read_api_token()},
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from cdiam_cli import api
|
|
6
|
+
from cdiam_cli.schemas.base import MessageResponseError, MessageResponseSuccess
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@click.group('data')
|
|
10
|
+
@click.pass_context
|
|
11
|
+
def data_cli(ctx):
|
|
12
|
+
"""
|
|
13
|
+
This command group provides various commands to show and manage data related to projects.
|
|
14
|
+
Use the subcommands under this group to interact with project effectively.
|
|
15
|
+
"""
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@data_cli.command('list')
|
|
20
|
+
@click.argument('project_id')
|
|
21
|
+
def list_all_data(project_id: str):
|
|
22
|
+
"""
|
|
23
|
+
This command lists all available data in given project id.
|
|
24
|
+
"""
|
|
25
|
+
try:
|
|
26
|
+
response: Any = api.api_action.run({
|
|
27
|
+
"api": "list_data",
|
|
28
|
+
"project_id": project_id
|
|
29
|
+
})
|
|
30
|
+
output = MessageResponseSuccess(data=response)
|
|
31
|
+
except Exception as e:
|
|
32
|
+
output = MessageResponseError(error=str(e))
|
|
33
|
+
click.echo(output.json())
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from cdiam_cli import api
|
|
6
|
+
from cdiam_cli.schemas.base import MessageResponseError, MessageResponseSuccess
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@click.group('project')
|
|
10
|
+
@click.pass_context
|
|
11
|
+
def project_cli(ctx):
|
|
12
|
+
"""
|
|
13
|
+
This command group provides various commands to show and manage data related to projects.
|
|
14
|
+
Use the subcommands under this group to interact with project effectively.
|
|
15
|
+
"""
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@project_cli.command('list')
|
|
20
|
+
def list_all_project():
|
|
21
|
+
"""
|
|
22
|
+
This command lists all the projects available in the system.
|
|
23
|
+
"""
|
|
24
|
+
try:
|
|
25
|
+
response: Any = api.api_action.run({"api": 'list_project'})
|
|
26
|
+
output = MessageResponseSuccess(data=response)
|
|
27
|
+
except Exception as e:
|
|
28
|
+
output = MessageResponseError(error=str(e))
|
|
29
|
+
click.echo(output.json())
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from cdiam_cli import api
|
|
4
|
+
from cdiam_cli.command import data, project
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@click.group()
|
|
8
|
+
@click.pass_context
|
|
9
|
+
def main_group(ctx):
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Groups
|
|
14
|
+
main_group.add_command(project.project_cli)
|
|
15
|
+
main_group.add_command(data.data_cli)
|
|
16
|
+
|
|
17
|
+
# Single command
|
|
18
|
+
main_group.add_command(api.call_api)
|
|
19
|
+
main_group.add_command(api.save_token)
|
|
20
|
+
|
|
21
|
+
if __name__ == "__main__":
|
|
22
|
+
main_group()
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Optional, List
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TaskStatus(BaseModel):
|
|
8
|
+
status: str = "UNKNOWN"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AnalysisResultBase(BaseModel):
|
|
12
|
+
result_id: str
|
|
13
|
+
data_id: str
|
|
14
|
+
analysis: int
|
|
15
|
+
task_id: str
|
|
16
|
+
args: str
|
|
17
|
+
project_id: str
|
|
18
|
+
user_email: Optional[str]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class AnalysisCatalogBase(BaseModel):
|
|
22
|
+
name: str
|
|
23
|
+
description: Optional[str]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class AnalysisCatalog(AnalysisCatalogBase):
|
|
27
|
+
"""
|
|
28
|
+
This table stores available analyses type
|
|
29
|
+
that the App supports.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
id: int
|
|
33
|
+
time_created: datetime
|
|
34
|
+
time_modified: datetime
|
|
35
|
+
"""A list of all analysis results of this type"""
|
|
36
|
+
results: List["AnalysisResult"]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class AnalysisResultRead(AnalysisResultBase):
|
|
40
|
+
"""
|
|
41
|
+
A response model of an anlysis result
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
time_created: datetime
|
|
45
|
+
time_modified: datetime
|
|
46
|
+
task: Optional[TaskStatus]
|
|
47
|
+
result_data_status: Optional[str]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class AnalysisResult(AnalysisResultBase):
|
|
51
|
+
"""
|
|
52
|
+
This table stores all analyses that had been produced for a data
|
|
53
|
+
The analysis reference points to the description of the analysis.
|
|
54
|
+
The result_id reference points to the detail result of the analysis
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
time_created: datetime
|
|
58
|
+
time_modified: datetime
|
|
59
|
+
"""An object of the analysis type"""
|
|
60
|
+
analysis_orm: AnalysisCatalog
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MessageStatusEnum(str, Enum):
|
|
8
|
+
SUCCESS = "success"
|
|
9
|
+
ERROR = "error"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MessageResponse(BaseModel):
|
|
13
|
+
status: MessageStatusEnum
|
|
14
|
+
error: str
|
|
15
|
+
data: Any
|
|
16
|
+
|
|
17
|
+
class Config:
|
|
18
|
+
allow_population_by_field_name = True
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class MessageResponseSuccess(MessageResponse):
|
|
22
|
+
status: MessageStatusEnum = MessageStatusEnum.SUCCESS
|
|
23
|
+
error: str = ""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class MessageResponseError(MessageResponse):
|
|
27
|
+
status: MessageStatusEnum = MessageStatusEnum.ERROR
|
|
28
|
+
data: Any = None
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from pydantic import validator
|
|
5
|
+
from cdiam_cli.schemas import ProjectSettings
|
|
6
|
+
from pydantic import BaseModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ProjectBase(BaseModel):
|
|
10
|
+
name: str
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Project(ProjectBase):
|
|
14
|
+
|
|
15
|
+
id: str
|
|
16
|
+
tombstone: Optional[bool]
|
|
17
|
+
time_created: datetime
|
|
18
|
+
is_public: bool
|
|
19
|
+
delete_date: Optional[datetime]
|
|
20
|
+
settings: Optional[str]
|
|
21
|
+
storage_used: int
|
|
22
|
+
created_by: str
|
|
23
|
+
|
|
24
|
+
@validator("settings")
|
|
25
|
+
def validate_settings(cls, v: str):
|
|
26
|
+
if v == "nan":
|
|
27
|
+
v = "{}"
|
|
28
|
+
if v is None:
|
|
29
|
+
v = "{}"
|
|
30
|
+
return ProjectSettings.encode_settings(ProjectSettings.decode_setting(v))
|
|
31
|
+
|
|
32
|
+
@validator("tombstone")
|
|
33
|
+
def validate_tombstone(cls, v):
|
|
34
|
+
if not v:
|
|
35
|
+
return False
|
|
36
|
+
return v
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
from pydantic import BaseModel
|
|
3
|
+
from typing import Union, List, Dict, Any
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ProjectSettings(BaseModel):
|
|
8
|
+
class Config:
|
|
9
|
+
orm_mode = True
|
|
10
|
+
|
|
11
|
+
cpdb: List[str] = []
|
|
12
|
+
enrichment: List[str] = []
|
|
13
|
+
|
|
14
|
+
@staticmethod
|
|
15
|
+
def encode_settings(settings: Union[Dict[str, Any], "ProjectSettings"]) -> str:
|
|
16
|
+
return ProjectSettings.parse_obj(settings).json()
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def decode_setting(settings: str) -> "ProjectSettings":
|
|
20
|
+
if settings is None:
|
|
21
|
+
settings = "{}"
|
|
22
|
+
return ProjectSettings.parse_obj(json.loads(settings))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ParamsRequestGetTaskStatus(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
Represents the parameters for a request to get the status of an analysis task.
|
|
28
|
+
|
|
29
|
+
:param api: The API endpoint being called, which should be "get_task_status".
|
|
30
|
+
:param task_id: The unique identifier of the analysis task.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
api: Literal["get_task_status"]
|
|
34
|
+
task_id: str
|
|
35
|
+
|
|
36
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "cdiam-cli"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["tungtp99 <tungtp181199@gmail.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -13,19 +13,13 @@ cdiam-cli = "cdiam_cli.main:main_group"
|
|
|
13
13
|
python = "^3.9"
|
|
14
14
|
click = "^8.1.7"
|
|
15
15
|
pyyaml = "^6.0.1"
|
|
16
|
-
tabulate = "^0.9.0"
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
datetime = "^5.5"
|
|
20
|
-
numpy = "^1.24.0"
|
|
21
|
-
pandas = "^2.1.0"
|
|
22
19
|
pydantic = "1.10.2"
|
|
23
|
-
sqlmodel = "0.0.8"
|
|
24
20
|
typing-extensions = "4.3.0"
|
|
25
|
-
sqlalchemy = "1.4.41"
|
|
26
|
-
sqlalchemy2-stubs = "0.0.2a27"
|
|
27
|
-
pymysql = "1.0.2"
|
|
28
21
|
idna = "3.4"
|
|
22
|
+
|
|
29
23
|
[build-system]
|
|
30
24
|
requires = ["poetry-core"]
|
|
31
25
|
build-backend = "poetry.core.masonry.api"
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
from pydantic import BaseModel
|
|
2
|
-
from typing import Literal, Optional
|
|
3
|
-
from sqlmodel import (
|
|
4
|
-
Field,
|
|
5
|
-
SQLModel,
|
|
6
|
-
ForeignKeyConstraint,
|
|
7
|
-
Column,
|
|
8
|
-
DateTime,
|
|
9
|
-
func,
|
|
10
|
-
Relationship,
|
|
11
|
-
UniqueConstraint,
|
|
12
|
-
BigInteger,
|
|
13
|
-
)
|
|
14
|
-
import sqlalchemy as sa
|
|
15
|
-
from pydantic import validator, BaseModel
|
|
16
|
-
from datetime import datetime
|
|
17
|
-
from typing import Union, Callable, ClassVar, Optional, List, Dict, Any
|
|
18
|
-
import json
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class ProjectSettings(BaseModel):
|
|
22
|
-
class Config:
|
|
23
|
-
orm_mode = True
|
|
24
|
-
|
|
25
|
-
cpdb: List[str] = []
|
|
26
|
-
enrichment: List[str] = []
|
|
27
|
-
|
|
28
|
-
@staticmethod
|
|
29
|
-
def encode_settings(settings: Union[Dict[str, Any], "ProjectSettings"]) -> str:
|
|
30
|
-
return ProjectSettings.parse_obj(settings).json()
|
|
31
|
-
|
|
32
|
-
@staticmethod
|
|
33
|
-
def decode_setting(settings: str) -> "ProjectSettings":
|
|
34
|
-
if settings is None:
|
|
35
|
-
settings = "{}"
|
|
36
|
-
return ProjectSettings.parse_obj(json.loads(settings))
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class ProjectBase(SQLModel):
|
|
40
|
-
name: str = Field(max_length=128, nullable=False)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class Project(ProjectBase, table=True):
|
|
44
|
-
__tablename__: ClassVar[Union[str, Callable[..., str]]] = "project"
|
|
45
|
-
id: str = Field(
|
|
46
|
-
max_length=128, nullable=False, primary_key=True, index=True, unique=True
|
|
47
|
-
)
|
|
48
|
-
tombstone: Optional[bool] = Field(
|
|
49
|
-
default=False,
|
|
50
|
-
nullable=False,
|
|
51
|
-
description="Deleted marker of the project. True = deleted",
|
|
52
|
-
)
|
|
53
|
-
time_created: datetime = Field(
|
|
54
|
-
default=None,
|
|
55
|
-
sa_column=Column(DateTime(timezone=True), server_default=func.now()),
|
|
56
|
-
description="Time added",
|
|
57
|
-
)
|
|
58
|
-
is_public: bool = Field(
|
|
59
|
-
default=False,
|
|
60
|
-
nullable=False,
|
|
61
|
-
description="If the project is public",
|
|
62
|
-
)
|
|
63
|
-
delete_date: Optional[datetime] = Field(
|
|
64
|
-
default=None, sa_column=Column(sa.DateTime(timezone=True), nullable=True)
|
|
65
|
-
)
|
|
66
|
-
settings: Optional[str] = Field(
|
|
67
|
-
default=None,
|
|
68
|
-
max_length=10240,
|
|
69
|
-
nullable=True,
|
|
70
|
-
)
|
|
71
|
-
storage_used: int = Field(
|
|
72
|
-
sa_column=Column(BigInteger),
|
|
73
|
-
nullable=True,
|
|
74
|
-
description="Non-zero expression values",
|
|
75
|
-
)
|
|
76
|
-
created_by: str = Field(
|
|
77
|
-
max_length=128,
|
|
78
|
-
nullable=False,
|
|
79
|
-
index=True,
|
|
80
|
-
foreign_key="user.email",
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
@validator("settings")
|
|
84
|
-
def validate_settings(cls, v: str):
|
|
85
|
-
if v == "nan":
|
|
86
|
-
v = "{}"
|
|
87
|
-
if v is None:
|
|
88
|
-
v = "{}"
|
|
89
|
-
return ProjectSettings.encode_settings(ProjectSettings.decode_setting(v))
|
|
90
|
-
|
|
91
|
-
@validator("tombstone")
|
|
92
|
-
def validate_tombstone(cls, v):
|
|
93
|
-
if not v:
|
|
94
|
-
return False
|
|
95
|
-
return v
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
class ParamsRequestGetTaskStatus(BaseModel):
|
|
99
|
-
"""
|
|
100
|
-
Represents the parameters for a request to get the status of an analysis task.
|
|
101
|
-
|
|
102
|
-
:param api: The API endpoint being called, which should be "get_task_status".
|
|
103
|
-
:param task_id: The unique identifier of the analysis task.
|
|
104
|
-
"""
|
|
105
|
-
|
|
106
|
-
api: Literal["get_task_status"]
|
|
107
|
-
task_id: str
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
class TaskStatus(BaseModel):
|
|
111
|
-
status: str = "UNKNOWN"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
class AnalysisResultBase(SQLModel):
|
|
115
|
-
result_id: str = Field(
|
|
116
|
-
max_length=128,
|
|
117
|
-
nullable=False,
|
|
118
|
-
primary_key=True,
|
|
119
|
-
description="ID of the analysis",
|
|
120
|
-
)
|
|
121
|
-
data_id: str = Field(max_length=128, nullable=False, description="ID of the data")
|
|
122
|
-
analysis: int = Field(
|
|
123
|
-
nullable=False,
|
|
124
|
-
foreign_key="analysis_catalog.id",
|
|
125
|
-
description="Reference to the analysis",
|
|
126
|
-
)
|
|
127
|
-
task_id: str = Field(
|
|
128
|
-
max_length=128,
|
|
129
|
-
nullable=False,
|
|
130
|
-
sa_column_kwargs={"server_default": ""},
|
|
131
|
-
description="ID of task in celery",
|
|
132
|
-
)
|
|
133
|
-
args: str = Field(
|
|
134
|
-
max_length=10240,
|
|
135
|
-
default="{}",
|
|
136
|
-
nullable=False,
|
|
137
|
-
description="Args of the analysis",
|
|
138
|
-
sa_column_kwargs={"server_default": "{}"},
|
|
139
|
-
)
|
|
140
|
-
project_id: str = Field(
|
|
141
|
-
max_length=128,
|
|
142
|
-
nullable=False,
|
|
143
|
-
description="ID of project this analysis belong to",
|
|
144
|
-
)
|
|
145
|
-
user_email: Optional[str] = Field(max_length=256, nullable=True)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
class AnalysisCatalogBase(SQLModel):
|
|
149
|
-
name: str = Field(nullable=False, description="Name of the analysis")
|
|
150
|
-
description: Optional[str] = Field(
|
|
151
|
-
max_length=4096, description="Detailed information about this analysis"
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
class AnalysisCatalog(AnalysisCatalogBase, table=True):
|
|
156
|
-
"""
|
|
157
|
-
This table stores available analyses type
|
|
158
|
-
that the App supports.
|
|
159
|
-
"""
|
|
160
|
-
|
|
161
|
-
__tablename__: ClassVar[Union[str, Callable[..., str]]] = "analysis_catalog"
|
|
162
|
-
id: int = Field(primary_key=True)
|
|
163
|
-
time_created: datetime = Field(
|
|
164
|
-
sa_column=Column(DateTime(timezone=True), server_default=func.now()),
|
|
165
|
-
description="Time added",
|
|
166
|
-
)
|
|
167
|
-
time_modified: datetime = Field(
|
|
168
|
-
sa_column=Column(
|
|
169
|
-
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
|
|
170
|
-
),
|
|
171
|
-
description="Time modified",
|
|
172
|
-
)
|
|
173
|
-
"""A list of all analysis results of this type"""
|
|
174
|
-
results: List["AnalysisResult"] = Relationship(back_populates="analysis_orm")
|
|
175
|
-
|
|
176
|
-
__table_args__ = (UniqueConstraint("name", name="_name_analysis_uc"),)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
class AnalysisResultRead(AnalysisResultBase):
|
|
180
|
-
"""
|
|
181
|
-
A response model of an anlysis result
|
|
182
|
-
"""
|
|
183
|
-
|
|
184
|
-
time_created: datetime
|
|
185
|
-
time_modified: datetime
|
|
186
|
-
task: Optional[TaskStatus]
|
|
187
|
-
result_data_status: Optional[str]
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
class AnalysisResult(AnalysisResultBase, table=True):
|
|
191
|
-
__tablename__: ClassVar[Union[str, Callable[..., str]]] = "analysis_result"
|
|
192
|
-
__table_args__ = (
|
|
193
|
-
ForeignKeyConstraint(
|
|
194
|
-
["project_id"], ["project.id"], onupdate="CASCADE", ondelete="CASCADE"
|
|
195
|
-
),
|
|
196
|
-
)
|
|
197
|
-
"""
|
|
198
|
-
This table stores all analyses that had been produced for a data
|
|
199
|
-
The analysis reference points to the description of the analysis.
|
|
200
|
-
The result_id reference points to the detail result of the analysis
|
|
201
|
-
"""
|
|
202
|
-
time_created: datetime = Field(
|
|
203
|
-
sa_column=Column(DateTime(timezone=True), server_default=func.now()),
|
|
204
|
-
description="Time added",
|
|
205
|
-
)
|
|
206
|
-
time_modified: datetime = Field(
|
|
207
|
-
sa_column=Column(
|
|
208
|
-
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
|
|
209
|
-
),
|
|
210
|
-
description="Time modified",
|
|
211
|
-
)
|
|
212
|
-
"""An object of the analysis type"""
|
|
213
|
-
analysis_orm: AnalysisCatalog = Relationship(back_populates="results")
|
|
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
|