Skip to content

Commit 1c22143

Browse files
committed
Refactor function db files based on SA's suggestion
1 parent f1041e1 commit 1c22143

File tree

5 files changed

+215
-181
lines changed

5 files changed

+215
-181
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Functions table
2+
3+
- List of functions served by the simcore platform
4+
"""
5+
6+
import uuid
7+
8+
import sqlalchemy as sa
9+
from sqlalchemy.dialects.postgresql import UUID
10+
11+
from .base import metadata
12+
13+
function_job_collections_table = sa.Table(
14+
"funcapi_function_job_collections",
15+
metadata,
16+
sa.Column(
17+
"uuid",
18+
UUID(as_uuid=True),
19+
default=uuid.uuid4,
20+
primary_key=True,
21+
index=True,
22+
doc="Unique id of the function job collection",
23+
),
24+
sa.Column(
25+
"title",
26+
sa.String,
27+
doc="Title of the function job collection",
28+
),
29+
sa.Column(
30+
"description",
31+
sa.String,
32+
doc="Description of the function job collection",
33+
),
34+
sa.PrimaryKeyConstraint("uuid", name="function_job_collections_pk"),
35+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""Functions table
2+
3+
- List of functions served by the simcore platform
4+
"""
5+
6+
import sqlalchemy as sa
7+
8+
from ._common import RefActions
9+
from .base import metadata
10+
from .funcapi_function_job_collections_table import function_job_collections_table
11+
from .funcapi_function_jobs_table import function_jobs_table
12+
13+
function_job_collections_to_function_jobs_table = sa.Table(
14+
"funcapi_function_job_collections_to_function_jobs",
15+
metadata,
16+
sa.Column(
17+
"function_job_collection_uuid",
18+
sa.ForeignKey(
19+
function_job_collections_table.c.uuid,
20+
onupdate=RefActions.CASCADE,
21+
ondelete=RefActions.CASCADE,
22+
name="fk_func_job_coll_to_func_jobs_to_func_job_coll_uuid",
23+
),
24+
doc="Unique identifier of the function job collection",
25+
),
26+
sa.Column(
27+
"function_job_uuid",
28+
sa.ForeignKey(
29+
function_jobs_table.c.uuid,
30+
onupdate=RefActions.CASCADE,
31+
ondelete=RefActions.CASCADE,
32+
name="fk_func_job_coll_to_func_jobs_to_func_job_uuid",
33+
),
34+
doc="Unique identifier of the function job",
35+
),
36+
)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""Functions table
2+
3+
- List of functions served by the simcore platform
4+
"""
5+
6+
import uuid
7+
8+
import sqlalchemy as sa
9+
from sqlalchemy.dialects.postgresql import UUID
10+
11+
from ._common import RefActions
12+
from .base import metadata
13+
from .funcapi_functions_table import functions_table
14+
15+
function_jobs_table = sa.Table(
16+
"funcapi_function_jobs",
17+
metadata,
18+
sa.Column(
19+
"uuid",
20+
UUID(as_uuid=True),
21+
primary_key=True,
22+
index=True,
23+
default=uuid.uuid4,
24+
doc="Unique id of the function job",
25+
),
26+
sa.Column(
27+
"title",
28+
sa.String,
29+
doc="Name of the function job",
30+
),
31+
sa.Column(
32+
"function_uuid",
33+
sa.ForeignKey(
34+
functions_table.c.uuid,
35+
onupdate=RefActions.CASCADE,
36+
ondelete=RefActions.CASCADE,
37+
name="fk_function_jobs_to_function_uuid",
38+
),
39+
nullable=False,
40+
index=True,
41+
doc="Unique identifier of the function",
42+
),
43+
sa.Column(
44+
"function_class",
45+
sa.String,
46+
doc="Class of the function",
47+
),
48+
sa.Column(
49+
"status",
50+
sa.String,
51+
doc="Status of the function job",
52+
),
53+
sa.Column(
54+
"inputs",
55+
sa.JSON,
56+
doc="Inputs of the function job",
57+
),
58+
sa.Column(
59+
"outputs",
60+
sa.JSON,
61+
doc="Outputs of the function job",
62+
),
63+
sa.Column(
64+
"class_specific_data",
65+
sa.JSON,
66+
nullable=True,
67+
doc="Fields specific for a function class",
68+
),
69+
sa.PrimaryKeyConstraint("uuid", name="function_jobs_pk"),
70+
)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""Functions table
2+
3+
- List of functions served by the simcore platform
4+
"""
5+
6+
import uuid
7+
8+
import sqlalchemy as sa
9+
from sqlalchemy.dialects.postgresql import UUID
10+
11+
from .base import metadata
12+
13+
functions_table = sa.Table(
14+
"funcapi_functions",
15+
metadata,
16+
sa.Column(
17+
"uuid",
18+
UUID(as_uuid=True),
19+
primary_key=True,
20+
index=True,
21+
default=uuid.uuid4,
22+
doc="Unique id of the function",
23+
),
24+
sa.Column(
25+
"title",
26+
sa.String,
27+
doc="Name of the function",
28+
),
29+
sa.Column(
30+
"function_class",
31+
sa.String,
32+
doc="Class of the function",
33+
),
34+
sa.Column(
35+
"description",
36+
sa.String,
37+
doc="Description of the function",
38+
),
39+
sa.Column(
40+
"input_schema",
41+
sa.JSON,
42+
doc="Input schema of the function",
43+
),
44+
sa.Column(
45+
"output_schema",
46+
sa.JSON,
47+
doc="Output schema of the function",
48+
),
49+
sa.Column(
50+
"system_tags",
51+
sa.JSON,
52+
nullable=True,
53+
doc="System-level tags of the function",
54+
),
55+
sa.Column(
56+
"user_tags",
57+
sa.JSON,
58+
nullable=True,
59+
doc="User-level tags of the function",
60+
),
61+
sa.Column(
62+
"class_specific_data",
63+
sa.JSON,
64+
nullable=True,
65+
doc="Fields specific for a function class",
66+
),
67+
sa.Column(
68+
"default_inputs",
69+
sa.JSON,
70+
nullable=True,
71+
doc="Default inputs of the function",
72+
),
73+
sa.PrimaryKeyConstraint("uuid", name="functions_pk"),
74+
)

0 commit comments

Comments
 (0)