From 244f8e413f85694bfde83c959c946835f5c10345 Mon Sep 17 00:00:00 2001 From: altescy Date: Wed, 24 Feb 2021 19:25:22 +0900 Subject: [PATCH] use open_file --- pdpcli/commands/apply.py | 2 +- pdpcli/commands/build.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pdpcli/commands/apply.py b/pdpcli/commands/apply.py index fdd200a..68324a5 100644 --- a/pdpcli/commands/apply.py +++ b/pdpcli/commands/apply.py @@ -108,7 +108,7 @@ def _is_pickle_file(file_path: Union[str, Path]) -> bool: def _load_pipeline_from_pickle( file_path: Union[str, Path]) -> pdpipe.PdPipelineStage: file_path = util.cached_path(file_path) - with open(file_path, "rb") as fp: + with util.open_file(file_path, "rb") as fp: pipeline = pickle.load(fp) return pipeline diff --git a/pdpcli/commands/build.py b/pdpcli/commands/build.py index 408cd0e..4816c67 100644 --- a/pdpcli/commands/build.py +++ b/pdpcli/commands/build.py @@ -4,10 +4,10 @@ import pdpipe # pylint: disable=unused-import -from pdpcli.configs import ConfigBuilder +from pdpcli.configs import ConfigBuilder, ConfigReader from pdpcli.data import DataReader from pdpcli.exceptions import ConfigurationError -from pdpcli.configs import ConfigReader +from pdpcli.util import open_file from pdpcli.commands.subcommand import Subcommand logger = logging.getLogger(__name__) @@ -67,7 +67,7 @@ def run(self, args: argparse.Namespace) -> None: pipeline.fit(df) logger.info("Save pipeline to: %s", args.pipeline) - with open(args.pipeline, "wb") as fp: + with open_file(args.pipeline, "wb") as fp: pickle.dump(pipeline, fp) logger.info("Done")