-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remaining dataclasses - warn on extra kwargs (#476)
* update feature domain init * update metric domain init * update parameter domain init * update artifact & dataframe domain init * fix repo import
- Loading branch information
Showing
8 changed files
with
323 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,65 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
from typing import TYPE_CHECKING, List, Optional | ||
|
||
from dataclasses import dataclass, field | ||
from datetime import datetime | ||
from typing import List, Optional | ||
from rubicon_ml.domain.mixin import CommentMixin, InitMixin, TagMixin | ||
|
||
from rubicon_ml.domain.mixin import CommentMixin, TagMixin | ||
from rubicon_ml.domain.utils import uuid | ||
if TYPE_CHECKING: | ||
from datetime import datetime | ||
|
||
|
||
@dataclass | ||
class Artifact(TagMixin, CommentMixin): | ||
name: str | ||
@dataclass(init=False) | ||
class Artifact(CommentMixin, InitMixin, TagMixin): | ||
"""A domain-level artifact. | ||
id: str = field(default_factory=uuid.uuid4) | ||
description: Optional[str] = None | ||
created_at: datetime = field(default_factory=datetime.utcnow) | ||
tags: List[str] = field(default_factory=list) | ||
comments: List[str] = field(default_factory=list) | ||
name : str | ||
The artifact's name. | ||
comments : list of str, optional | ||
Additional text information and observations about the artifact. Defaults to | ||
`None`. | ||
created_at : datetime, optional | ||
The date and time the artifact was created. Defaults to `None` and uses | ||
`datetime.datetime.now` to generate a UTC timestamp. `created_at` should be | ||
left as `None` to allow for automatic generation. | ||
description : str, optional | ||
A description of the artifact. Defaults to `None`. | ||
id : str, optional | ||
The artifact's unique identifier. Defaults to `None` and uses `uuid.uuid4` | ||
to generate a unique ID. `id` should be left as `None` to allow for automatic | ||
generation. | ||
parent_id : str, optional | ||
The unique identifier of the project or experiment the artifact belongs to. | ||
Defaults to `None`. | ||
tags : list of str, optional | ||
The values this artifact is tagged with. Defaults to `None`. | ||
""" | ||
|
||
name: str | ||
comments: Optional[List[str]] = None | ||
created_at: Optional["datetime"] = None | ||
description: Optional[str] = None | ||
id: Optional[str] = None | ||
parent_id: Optional[str] = None | ||
tags: Optional[List[str]] = None | ||
|
||
def __init__( | ||
self, | ||
name: str, | ||
comments: Optional[List[str]] = None, | ||
created_at: Optional["datetime"] = None, | ||
description: Optional[str] = None, | ||
id: Optional[str] = None, | ||
parent_id: Optional[str] = None, | ||
tags: Optional[List[str]] = None, | ||
**kwargs, | ||
): | ||
"""Initialize this domain artifact.""" | ||
|
||
self._check_extra_kwargs(kwargs) | ||
|
||
self.name = name | ||
self.comments = comments or [] | ||
self.created_at = self._init_created_at(created_at) | ||
self.description = description | ||
self.id = self._init_id(id) | ||
self.parent_id = parent_id | ||
self.tags = tags or [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,65 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
from typing import TYPE_CHECKING, List, Optional | ||
|
||
from dataclasses import dataclass, field | ||
from datetime import datetime | ||
from typing import List, Optional | ||
from rubicon_ml.domain.mixin import CommentMixin, InitMixin, TagMixin | ||
|
||
from rubicon_ml.domain.mixin import CommentMixin, TagMixin | ||
from rubicon_ml.domain.utils import uuid | ||
if TYPE_CHECKING: | ||
from datetime import datetime | ||
|
||
|
||
@dataclass | ||
class Dataframe(TagMixin, CommentMixin): | ||
id: str = field(default_factory=uuid.uuid4) | ||
name: Optional[str] = None | ||
description: Optional[str] = None | ||
tags: List[str] = field(default_factory=list) | ||
comments: List[str] = field(default_factory=list) | ||
created_at: datetime = field(default_factory=datetime.utcnow) | ||
@dataclass(init=False) | ||
class Dataframe(CommentMixin, InitMixin, TagMixin): | ||
"""A domain-level dataframe. | ||
comments : list of str, optional | ||
Additional text information and observations about the dataframe. Defaults to | ||
`None`. | ||
created_at : datetime, optional | ||
The date and time the dataframe was created. Defaults to `None` and uses | ||
`datetime.datetime.now` to generate a UTC timestamp. `created_at` should be | ||
left as `None` to allow for automatic generation. | ||
description : str, optional | ||
A description of the dataframe. Defaults to `None`. | ||
id : str, optional | ||
The dataframe's unique identifier. Defaults to `None` and uses `uuid.uuid4` | ||
to generate a unique ID. `id` should be left as `None` to allow for automatic | ||
generation. | ||
name : str, optional | ||
The dataframe's name. Defaults to `None`. | ||
parent_id : str, optional | ||
The unique identifier of the project or experiment the dataframe belongs to. | ||
Defaults to `None`. | ||
tags : list of str, optional | ||
The values this dataframe is tagged with. Defaults to `None`. | ||
""" | ||
|
||
comments: Optional[List[str]] = None | ||
created_at: Optional["datetime"] = None | ||
description: Optional[str] = None | ||
id: Optional[str] = None | ||
name: Optional[str] = None | ||
parent_id: Optional[str] = None | ||
tags: Optional[List[str]] = None | ||
|
||
def __init__( | ||
self, | ||
comments: Optional[List[str]] = None, | ||
created_at: Optional["datetime"] = None, | ||
description: Optional[str] = None, | ||
id: Optional[str] = None, | ||
name: Optional[str] = None, | ||
parent_id: Optional[str] = None, | ||
tags: Optional[List[str]] = None, | ||
**kwargs, | ||
): | ||
"""Initialize this doimain dataframe.""" | ||
|
||
self._check_extra_kwargs(kwargs) | ||
|
||
self.comments = comments or [] | ||
self.created_at = self._init_created_at(created_at) | ||
self.description = description | ||
self.id = self._init_id(id) | ||
self.name = name | ||
self.parent_id = parent_id | ||
self.tags = tags or [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,64 @@ | ||
from dataclasses import dataclass, field | ||
from datetime import datetime | ||
from typing import List, Optional | ||
from dataclasses import dataclass | ||
from typing import TYPE_CHECKING, List, Optional | ||
|
||
from rubicon_ml.domain.mixin import CommentMixin, TagMixin | ||
from rubicon_ml.domain.utils import uuid | ||
from rubicon_ml.domain.mixin import CommentMixin, InitMixin, TagMixin | ||
|
||
if TYPE_CHECKING: | ||
from datetime import datetime | ||
|
||
@dataclass | ||
class Feature(TagMixin, CommentMixin): | ||
name: str | ||
|
||
id: str = field(default_factory=uuid.uuid4) | ||
@dataclass(init=False) | ||
class Feature(CommentMixin, InitMixin, TagMixin): | ||
"""A domain-level feature. | ||
name : str | ||
The feature's name. | ||
comments : list of str, optional | ||
Additional text information and observations about the feature. Defaults to | ||
`None`. | ||
created_at : datetime, optional | ||
The date and time the feature was created. Defaults to `None` and uses | ||
`datetime.datetime.now` to generate a UTC timestamp. `created_at` should be | ||
left as `None` to allow for automatic generation. | ||
description : str, optional | ||
A description of the feature. Defaults to `None`. | ||
id : str, optional | ||
The feature's unique identifier. Defaults to `None` and uses `uuid.uuid4` | ||
to generate a unique ID. `id` should be left as `None` to allow for automatic | ||
generation. | ||
importance : float, optional | ||
The feature's calculated importance value. Defaults to `None`. | ||
tags : list of str, optional | ||
The values this feature is tagged with. Defaults to `None`. | ||
""" | ||
|
||
name: str | ||
comments: Optional[List[str]] = None | ||
created_at: Optional["datetime"] = None | ||
description: Optional[str] = None | ||
id: Optional[str] = None | ||
importance: Optional[float] = None | ||
tags: List[str] = field(default_factory=list) | ||
comments: List[str] = field(default_factory=list) | ||
created_at: datetime = field(default_factory=datetime.utcnow) | ||
tags: Optional[List[str]] = None | ||
|
||
def __init__( | ||
self, | ||
name: str, | ||
comments: Optional[List[str]] = None, | ||
created_at: Optional["datetime"] = None, | ||
description: Optional[str] = None, | ||
id: Optional[str] = None, | ||
importance: Optional[float] = None, | ||
tags: Optional[List[str]] = None, | ||
**kwargs, | ||
): | ||
"""Initialize this domain feature.""" | ||
|
||
self._check_extra_kwargs(kwargs) | ||
|
||
self.name = name | ||
self.comments = comments or [] | ||
self.created_at = self._init_created_at(created_at) | ||
self.description = description | ||
self.id = self._init_id(id) | ||
self.importance = importance | ||
self.tags = tags or [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,75 @@ | ||
from dataclasses import dataclass, field | ||
from datetime import datetime | ||
from typing import List, Optional | ||
from dataclasses import dataclass | ||
from typing import TYPE_CHECKING, Any, List, Literal, Optional | ||
|
||
from rubicon_ml.domain.mixin import CommentMixin, TagMixin | ||
from rubicon_ml.domain.utils import uuid | ||
from rubicon_ml.domain.mixin import CommentMixin, InitMixin, TagMixin | ||
|
||
if TYPE_CHECKING: | ||
from datetime import datetime | ||
|
||
DIRECTIONALITY_VALUES = ["score", "loss"] | ||
|
||
|
||
@dataclass | ||
class Metric(TagMixin, CommentMixin): | ||
name: str | ||
value: float | ||
@dataclass(init=False) | ||
class Metric(CommentMixin, InitMixin, TagMixin): | ||
"""A domain-level metric. | ||
id: str = field(default_factory=uuid.uuid4) | ||
name : str | ||
The metric's name. | ||
value : any | ||
The metric's value. | ||
comments : list of str, optional | ||
Additional text information and observations about the metric. Defaults to | ||
`None`. | ||
created_at : datetime, optional | ||
The date and time the metric was created. Defaults to `None` and uses | ||
`datetime.datetime.now` to generate a UTC timestamp. `created_at` should be | ||
left as `None` to allow for automatic generation. | ||
description : str, optional | ||
A description of the metric. Defaults to `None`. | ||
directionality : "score" or "loss", optional | ||
"score" to indicate greater values are better, "loss" to indiciate smaller | ||
values are better. Defaults to "score". | ||
id : str, optional | ||
The metric's unique identifier. Defaults to `None` and uses `uuid.uuid4` | ||
to generate a unique ID. `id` should be left as `None` to allow for automatic | ||
generation. | ||
tags : list of str, optional | ||
The values this metric is tagged with. Defaults to `None`. | ||
""" | ||
|
||
name: str | ||
value: Any | ||
comments: Optional[List[str]] = None | ||
created_at: Optional["datetime"] = None | ||
description: Optional[str] = None | ||
directionality: str = "score" | ||
created_at: datetime = field(default_factory=datetime.utcnow) | ||
tags: List[str] = field(default_factory=list) | ||
comments: List[str] = field(default_factory=list) | ||
|
||
def __post_init__(self): | ||
if self.directionality not in DIRECTIONALITY_VALUES: | ||
raise ValueError(f"metric directionality must be one of {DIRECTIONALITY_VALUES}") | ||
directionality: Literal["score", "loss"] = "score" | ||
id: Optional[str] = None | ||
tags: Optional[List[str]] = None | ||
|
||
def __init__( | ||
self, | ||
name: str, | ||
value: Any, | ||
comments: Optional[List[str]] = None, | ||
created_at: Optional["datetime"] = None, | ||
description: Optional[str] = None, | ||
directionality: Literal["score", "loss"] = "score", | ||
id: Optional[str] = None, | ||
tags: Optional[List[str]] = None, | ||
**kwargs, | ||
): | ||
"""Initialize this domain metric.""" | ||
|
||
if directionality not in DIRECTIONALITY_VALUES: | ||
raise ValueError(f"`directionality` must be one of {DIRECTIONALITY_VALUES}") | ||
|
||
self._check_extra_kwargs(kwargs) | ||
|
||
self.name = name | ||
self.value = value | ||
self.comments = comments or [] | ||
self.created_at = self._init_created_at(created_at) | ||
self.description = description | ||
self.directionality = directionality | ||
self.id = self._init_id(id) | ||
self.tags = tags or [] |
Oops, something went wrong.