Skip to content

Commit cd6435c

Browse files
committed
Add related ID fields to resources
1 parent 448078b commit cd6435c

File tree

7 files changed

+38
-1
lines changed

7 files changed

+38
-1
lines changed

metafold/assets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ class Asset:
1919
checksum: File checksum.
2020
created: Asset creation datetime.
2121
modified: Asset last modified datetime.
22+
project_id: Project ID.
2223
"""
2324
id: str
2425
filename: str
2526
size: int
2627
checksum: str
2728
created: datetime = field(converter=asdatetime)
2829
modified: datetime = field(converter=asdatetime)
30+
project_id: str
2931

3032

3133
class AssetsEndpoint:

metafold/jobs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class Job:
6161
error: Error message for failed jobs.
6262
inputs: Input assets and parameters.
6363
outputs: Output assets and parameters.
64+
needs: List of upstream job IDs in a workflow graph.
65+
project_id: Project ID.
66+
workflow_id: Workflow ID.
6467
assets: (Deprecated) List of generated asset resources.
6568
parameters: (Deprecated) Job parameters.
6669
meta: (Deprecated) Additional metadata generated by the job.
@@ -78,6 +81,8 @@ class Job:
7881
inputs: IO = field(converter=lambda v: v if isinstance(v, IO) else IO.from_dict(v))
7982
outputs: IO = field(converter=lambda v: v if isinstance(v, IO) else IO.from_dict(v))
8083
needs: list[str]
84+
project_id: Optional[str] = None
85+
workflow_id: Optional[str] = None
8186
# NOTE(ryan): Deprecated
8287
assets: Optional[list[Asset]] = field(
8388
converter=lambda v: optional(_assets)(v), default=None)

metafold/workflows.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Workflow:
1919
started: Workflow started datetime.
2020
finished: Workflow finished datetime.
2121
definition: Workflow definition string.
22+
project_id: Project ID.
2223
"""
2324
id: str
2425
jobs: list[str] = field(factory=list)
@@ -29,6 +30,7 @@ class Workflow:
2930
finished: Optional[datetime] = field(
3031
converter=lambda v: optional_datetime(v), default=None)
3132
definition: str
33+
project_id: str
3234

3335

3436
class WorkflowsEndpoint:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "metafold"
7-
version = "0.8.dev1"
7+
version = "0.8.dev2"
88
authors = [
99
{name = "Metafold 3D", email = "[email protected]"},
1010
]

tests/test_assets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"checksum": "sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c",
2525
"created": "Mon, 01 Jan 2024 00:00:00 GMT",
2626
"modified": "Mon, 01 Jan 2024 00:00:00 GMT",
27+
"project_id": "1",
2728
},
2829
{
2930
"id": "2",
@@ -32,6 +33,7 @@
3233
"checksum": "sha256:6310a5951d58eb3e0fdd8c8767c606615552899e65019cb1582508a7c7bfec39",
3334
"created": "Mon, 01 Jan 2024 00:00:00 GMT",
3435
"modified": "Mon, 01 Jan 2024 00:00:00 GMT",
36+
"project_id": "1",
3537
},
3638
{
3739
"id": "1",
@@ -40,6 +42,7 @@
4042
"checksum": "sha256:6310a5951d58eb3e0fdd8c8767c606615552899e65019cb1582508a7c7bfec39",
4143
"created": "Mon, 01 Jan 2024 00:00:00 GMT",
4244
"modified": "Mon, 01 Jan 2024 00:00:00 GMT",
45+
"project_id": "1",
4346
},
4447
]
4548

@@ -50,6 +53,7 @@
5053
"checksum": "sha256:089ad5bf4831b6758e9907db43bc5ebba2e9248a9929dad6132c49932e538278",
5154
"created": "Mon, 01 Jan 2024 00:00:00 GMT",
5255
"modified": "Mon, 01 Jan 2024 00:00:00 GMT",
56+
"project_id": "1",
5357
}
5458

5559

@@ -149,6 +153,7 @@ def test_get_asset(client):
149153
checksum="sha256:6310a5951d58eb3e0fdd8c8767c606615552899e65019cb1582508a7c7bfec39",
150154
created=default_dt,
151155
modified=default_dt,
156+
project_id="1",
152157
)
153158

154159

@@ -168,6 +173,7 @@ def test_create_asset(client):
168173
checksum="sha256:089ad5bf4831b6758e9907db43bc5ebba2e9248a9929dad6132c49932e538278",
169174
created=default_dt,
170175
modified=default_dt,
176+
project_id="1",
171177
)
172178

173179

tests/test_jobs.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"checksum": "sha256:6310a5951d58eb3e0fdd8c8767c606615552899e65019cb1582508a7c7bfec39",
2323
"created": "Mon, 01 Jan 2024 00:00:00 GMT",
2424
"modified": "Mon, 01 Jan 2024 00:00:00 GMT",
25+
"project_id": "1",
2526
}
2627

2728
asset_obj = Asset(
@@ -31,6 +32,7 @@
3132
checksum="sha256:6310a5951d58eb3e0fdd8c8767c606615552899e65019cb1582508a7c7bfec39",
3233
created=default_dt,
3334
modified=default_dt,
35+
project_id="1",
3436
)
3537

3638
# Default sort order is descending by id
@@ -51,6 +53,8 @@
5153
"params": None,
5254
},
5355
"needs": [],
56+
"project_id": "1",
57+
"workflow_id": None,
5458
"parameters": default_params,
5559
"meta": None,
5660
},
@@ -70,6 +74,8 @@
7074
"params": None,
7175
},
7276
"needs": [],
77+
"project_id": "1",
78+
"workflow_id": None,
7379
"parameters": default_params,
7480
"meta": None,
7581
},
@@ -89,6 +95,8 @@
8995
"params": None,
9096
},
9197
"needs": [],
98+
"project_id": "1",
99+
"workflow_id": None,
92100
"parameters": default_params,
93101
"meta": None,
94102
},
@@ -113,6 +121,8 @@
113121
"params": None,
114122
},
115123
"needs": [],
124+
"project_id": "1",
125+
"workflow_id": None,
116126
"assets": [],
117127
"parameters": {
118128
"foo": "1",
@@ -229,6 +239,8 @@ def test_get_job(client):
229239
inputs=IO(params=default_params),
230240
outputs=IO(),
231241
needs=[],
242+
project_id="1",
243+
workflow_id=None,
232244
assets=[asset_obj],
233245
parameters=default_params,
234246
meta=None,
@@ -253,6 +265,8 @@ def test_run_job(client):
253265
inputs=IO(params=params),
254266
outputs=IO(),
255267
needs=[],
268+
project_id="1",
269+
workflow_id=None,
256270
assets=[asset_obj],
257271
parameters=params,
258272
meta=None,
@@ -280,6 +294,8 @@ def test_poll_job(client):
280294
inputs=IO(params=params),
281295
outputs=IO(),
282296
needs=[],
297+
project_id="1",
298+
workflow_id=None,
283299
assets=[asset_obj],
284300
parameters=params,
285301
meta=None,

tests/test_workflows.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"started": "Mon, 01 Jan 2024 00:00:00 GMT",
2020
"finished": "Mon, 01 Jan 2024 00:00:00 GMT",
2121
"definition": "...",
22+
"project_id": "1",
2223
},
2324
{
2425
"id": "2",
@@ -28,6 +29,7 @@
2829
"started": "Mon, 01 Jan 2024 00:00:00 GMT",
2930
"finished": "Mon, 01 Jan 2024 00:00:00 GMT",
3031
"definition": "...",
32+
"project_id": "1",
3133
},
3234
{
3335
"id": "1",
@@ -37,6 +39,7 @@
3739
"started": "Mon, 01 Jan 2024 00:00:00 GMT",
3840
"finished": "Mon, 01 Jan 2024 00:00:00 GMT",
3941
"definition": "...",
42+
"project_id": "1",
4043
},
4144
]
4245

@@ -47,6 +50,7 @@
4750
"started": "Mon, 01 Jan 2024 00:00:00 GMT",
4851
"finished": "Mon, 01 Jan 2024 00:00:00 GMT",
4952
"definition": "foo",
53+
"project_id": "1",
5054
}
5155

5256
poll_count: int = 0
@@ -134,6 +138,7 @@ def test_get_workflow(client):
134138
started=default_dt,
135139
finished=default_dt,
136140
definition="...",
141+
project_id="1",
137142
)
138143

139144

@@ -148,4 +153,5 @@ def test_run_workflow(client):
148153
started=default_dt,
149154
finished=default_dt,
150155
definition=definition,
156+
project_id="1",
151157
)

0 commit comments

Comments
 (0)