|
8 | 8 |
|
9 | 9 | from datetime import datetime |
10 | 10 | from enum import Enum |
11 | | - |
12 | | -# /data-export |
| 11 | +from pathlib import Path |
13 | 12 | from typing import Annotated, Any, Literal, Self, TypeAlias |
14 | 13 | from uuid import UUID |
15 | 14 |
|
16 | | -from models_library.projects import ProjectID |
17 | | -from models_library.users import UserID |
18 | 15 | from pydantic import ( |
19 | 16 | BaseModel, |
20 | 17 | ByteSize, |
|
28 | 25 | ) |
29 | 26 | from pydantic.networks import AnyUrl |
30 | 27 |
|
31 | | -from ..basic_regex import DATCORE_DATASET_NAME_RE, S3_BUCKET_NAME_RE |
| 28 | +from ..basic_regex import ( |
| 29 | + DATCORE_COLLECTION_NAME_RE, |
| 30 | + DATCORE_DATASET_NAME_RE, |
| 31 | + DATCORE_FILE_ID_RE, |
| 32 | + S3_BUCKET_NAME_RE, |
| 33 | +) |
32 | 34 | from ..basic_types import SHA256Str |
33 | 35 | from ..generics import ListModel |
| 36 | +from ..projects import ProjectID |
34 | 37 | from ..projects_nodes_io import ( |
35 | 38 | LocationID, |
36 | 39 | LocationName, |
37 | 40 | NodeID, |
38 | 41 | SimcoreS3FileID, |
39 | 42 | StorageFileID, |
40 | 43 | ) |
| 44 | +from ..users import UserID |
41 | 45 |
|
42 | 46 | ETag: TypeAlias = str |
43 | 47 |
|
|
46 | 50 | DatCoreDatasetName: TypeAlias = Annotated[ |
47 | 51 | str, StringConstraints(pattern=DATCORE_DATASET_NAME_RE) |
48 | 52 | ] |
| 53 | +DatCoreCollectionName: TypeAlias = Annotated[ |
| 54 | + str, StringConstraints(pattern=DATCORE_COLLECTION_NAME_RE) |
| 55 | +] |
| 56 | +DatCorePackageName: TypeAlias = Annotated[ |
| 57 | + str, StringConstraints(pattern=DATCORE_FILE_ID_RE) |
| 58 | +] |
49 | 59 |
|
50 | 60 |
|
51 | 61 | # / |
@@ -263,9 +273,6 @@ class FileMetaDataArray(RootModel[list[FileMetaDataGet]]): |
263 | 273 | root: list[FileMetaDataGet] = Field(default_factory=list) |
264 | 274 |
|
265 | 275 |
|
266 | | -# /locations/{location_id}/files/{file_id} |
267 | | - |
268 | | - |
269 | 276 | class LinkType(str, Enum): |
270 | 277 | PRESIGNED = "PRESIGNED" |
271 | 278 | S3 = "S3" |
@@ -370,3 +377,53 @@ def ensure_consistent_entries(self: Self) -> Self: |
370 | 377 |
|
371 | 378 | class SoftCopyBody(BaseModel): |
372 | 379 | link_id: SimcoreS3FileID |
| 380 | + |
| 381 | + |
| 382 | +class PathMetaDataGet(BaseModel): |
| 383 | + path: Annotated[Path, Field(description="the path to the current path")] |
| 384 | + display_path: Annotated[ |
| 385 | + Path, Field(description="the path to display with UUID replaced") |
| 386 | + ] |
| 387 | + |
| 388 | + file_meta_data: Annotated[ |
| 389 | + FileMetaDataGet | None, |
| 390 | + Field(description="if filled, this is the file meta data of the s3 object"), |
| 391 | + ] = None |
| 392 | + |
| 393 | + model_config = ConfigDict( |
| 394 | + extra="forbid", |
| 395 | + json_schema_extra={ |
| 396 | + "examples": [ |
| 397 | + # ls no filter |
| 398 | + { |
| 399 | + "path": "f8da77a9-24b9-4eab-aee7-1f0608da1e3e", |
| 400 | + "display_path": "my amazing project", |
| 401 | + }, |
| 402 | + # ls f8da77a9-24b9-4eab-aee7-1f0608da1e3e |
| 403 | + { |
| 404 | + "path": "f8da77a9-24b9-4eab-aee7-1f0608da1e3e/2f94f80f-633e-4dfa-a983-226b7babe3d7", |
| 405 | + "display_path": "my amazing project/awesome node", |
| 406 | + }, |
| 407 | + # ls f8da77a9-24b9-4eab-aee7-1f0608da1e3e/2f94f80f-633e-4dfa-a983-226b7babe3d7 |
| 408 | + { |
| 409 | + "path": "f8da77a9-24b9-4eab-aee7-1f0608da1e3e/2f94f80f-633e-4dfa-a983-226b7babe3d7/outputs", |
| 410 | + "display_path": "my amazing project/awesome node/outputs", |
| 411 | + }, |
| 412 | + # ls f8da77a9-24b9-4eab-aee7-1f0608da1e3e/2f94f80f-633e-4dfa-a983-226b7babe3d7/outputs |
| 413 | + { |
| 414 | + "path": "f8da77a9-24b9-4eab-aee7-1f0608da1e3e/2f94f80f-633e-4dfa-a983-226b7babe3d7/outputs/output5", |
| 415 | + "display_path": "my amazing project/awesome node/outputs/output5", |
| 416 | + }, |
| 417 | + # ls f8da77a9-24b9-4eab-aee7-1f0608da1e3e/2f94f80f-633e-4dfa-a983-226b7babe3d7/outputs/output_5 |
| 418 | + { |
| 419 | + "path": f"f8da77a9-24b9-4eab-aee7-1f0608da1e3e/2f94f80f-633e-4dfa-a983-226b7babe3d7/outputs/output5/{FileMetaDataGet.model_config['json_schema_extra']['examples'][0]['file_name']}", # type: ignore[index, call-overload] |
| 420 | + "display_path": f"my amazing project/awesome node/outputs/output5/{FileMetaDataGet.model_config['json_schema_extra']['examples'][0]['file_name']}", # type: ignore[index, call-overload] |
| 421 | + "file_meta_data": FileMetaDataGet.model_config["json_schema_extra"][ # type: ignore[index] |
| 422 | + "examples" |
| 423 | + ][ |
| 424 | + 0 # type: ignore[index] |
| 425 | + ], |
| 426 | + }, |
| 427 | + ] |
| 428 | + }, |
| 429 | + ) |
0 commit comments