Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit c0f133d

Browse files
committed
df: types: Make DataFlow not a dataclass
* dataclasses.asdict recursively converts dataclasses into dicts. This resulted in the DataFlow.export method not being called and by_origin ending up in configs which had DataFlows as a property (dffml.dataflow.run). By making DataFlow a regular class and not a dataclass we avoid this issue. Signed-off-by: John Andersen <[email protected]>
1 parent b054fb3 commit c0f133d

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Add python code for tensorflow DNNEstimator
1515
### Fixed
1616
- New model tutorial mentions file paths that should be edited.
17+
- DataFlow is no longer a dataclass to prevent it from being exported
18+
incorrectly.
1719

1820
## [0.3.5] - 2020-03-10
1921
### Added

dffml/df/types.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -412,22 +412,33 @@ def _fromdict(cls, **kwargs):
412412
return cls(**kwargs)
413413

414414

415-
@dataclass
416415
class DataFlow:
417-
operations: Dict[str, Union[Operation, Callable]]
418-
seed: List[Input] = field(default=None)
419-
configs: Dict[str, BaseConfig] = field(default=None)
420-
definitions: Dict[str, Definition] = field(init=False)
421-
flow: Dict[str, InputFlow] = field(default=None)
422-
by_origin: Dict[Stage, Dict[str, Operation]] = field(default=None)
423-
# Implementations can be provided in case they haven't been registered via
424-
# the entrypoint system.
425-
implementations: Dict[str, "OperationImplementation"] = field(default=None)
426-
forward: Forward = field(default_factory=lambda: Forward())
416+
def __init__(
417+
self,
418+
operations: Dict[str, Union[Operation, Callable]],
419+
seed: List[Input] = None,
420+
configs: Dict[str, BaseConfig] = None,
421+
definitions: Dict[str, Definition] = False,
422+
flow: Dict[str, InputFlow] = None,
423+
by_origin: Dict[Stage, Dict[str, Operation]] = None,
424+
# Implementations can be provided in case they haven't been registered
425+
# via the entrypoint system.
426+
implementations: Dict[str, "OperationImplementation"] = None,
427+
forward: Forward = None,
428+
) -> None:
429+
self.operations = operations
430+
self.seed = seed
431+
self.configs = configs
432+
self.definitions = definitions
433+
self.flow = flow
434+
self.by_origin = by_origin
435+
self.implementations = implementations
436+
self.forward = forward
427437

428-
def __post_init__(self):
429438
# Prevent usage of a global dict (if we set default to {} then all the
430439
# instances will share the same instance of that dict, or list)
440+
if self.forward is None:
441+
self.forward = Forward()
431442
if self.seed is None:
432443
self.seed = []
433444
if self.configs is None:

0 commit comments

Comments
 (0)