Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
refactor: set default serializer in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
hollandjg committed Oct 24, 2023
1 parent 904b58f commit 9318e55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/autora/serializer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SerializersSupported(str, Enum):
SerializersSupported.dill: _SerializerDef("dill", "load", "dump", "dumps", "b"),
}

_default_serializer = SerializersSupported.pickle
default_serializer = SerializersSupported.pickle


def _get_serializer_mode(
Expand All @@ -49,7 +49,7 @@ def _get_serializer_mode(

def load_state(
path: Optional[pathlib.Path],
loader: SerializersSupported = _default_serializer,
loader: SerializersSupported = default_serializer,
) -> Union[State, None]:
"""Load a State object from a path."""
if path is not None:
Expand All @@ -66,7 +66,7 @@ def load_state(
def dump_state(
state_: State,
path: Optional[pathlib.Path],
dumper: SerializersSupported = _default_serializer,
dumper: SerializersSupported = default_serializer,
) -> None:
"""Write a State object to a path."""
if path is not None:
Expand Down
11 changes: 8 additions & 3 deletions src/autora/workflow/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
import typer
from typing_extensions import Annotated

from autora.serializer import SerializersSupported, dump_state, load_state
from autora.serializer import (
SerializersSupported,
default_serializer,
dump_state,
load_state,
)

_logger = logging.getLogger(__name__)

Expand All @@ -27,7 +32,7 @@ def main(
typer.Option(
help="(de)serializer to load the data",
),
] = SerializersSupported.dill,
] = default_serializer,
out_path: Annotated[
Optional[pathlib.Path],
typer.Option(help="Path to output the final state"),
Expand All @@ -37,7 +42,7 @@ def main(
typer.Option(
help="serializer to save the data",
),
] = SerializersSupported.dill,
] = default_serializer,
verbose: Annotated[bool, typer.Option(help="Turns on info logging level.")] = False,
debug: Annotated[bool, typer.Option(help="Turns on debug logging level.")] = False,
):
Expand Down

0 comments on commit 9318e55

Please sign in to comment.