Skip to content

Commit

Permalink
chore: descritpion.md are now optional
Browse files Browse the repository at this point in the history
Signed-off-by: ThibaultFy <[email protected]>
  • Loading branch information
ThibaultFy committed Jun 19, 2024
1 parent d9961cc commit d530023
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion substra/sdk/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import enum
import json
import pathlib
import tempfile
import typing
import uuid
from typing import Dict
Expand All @@ -19,6 +20,13 @@
"summary_task": "task",
}

GENERATED_DESCRIPTION_CONTENT = """
# No description given
To add a dataset description, create a markdown file and pass it to your
`substra.sdk.schemasDatasetSpec` on your dataset opener registration.
"""


class BackendType(str, enum.Enum):
REMOTE = "remote"
Expand Down Expand Up @@ -282,13 +290,24 @@ class DatasetSpec(_Spec):

name: str
data_opener: pathlib.Path # Path to the data opener
description: pathlib.Path # Path to the description file
description: Optional[pathlib.Path] = None # Path to the description file
permissions: Permissions
metadata: Optional[Dict[str, str]] = None
logs_permission: Permissions

type_: typing.ClassVar[Type] = Type.Dataset

@pydantic.model_validator(mode="before")
@classmethod
def _check_description(cls, values):
if "description" not in values:
parent_path = pathlib.Path(values["data_opener"]).parent
description_path = parent_path / "generated_description.md"
with description_path.open("w", encoding="utf-8") as f:
f.write(GENERATED_DESCRIPTION_CONTENT)
values["description"] = description_path
return values

class Meta:
file_attributes = (
"data_opener",
Expand Down

0 comments on commit d530023

Please sign in to comment.