From 282497674936f0cc169a2dfa103169ef063202e5 Mon Sep 17 00:00:00 2001 From: Darryl Melander Date: Tue, 11 May 2021 14:04:25 -0600 Subject: [PATCH] Add class that handles different input file formats --- prescient/data/data_provider_factory.py | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 prescient/data/data_provider_factory.py diff --git a/prescient/data/data_provider_factory.py b/prescient/data/data_provider_factory.py new file mode 100644 index 00000000..0edb598a --- /dev/null +++ b/prescient/data/data_provider_factory.py @@ -0,0 +1,30 @@ +# ___________________________________________________________________________ +# +# Prescient +# Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC +# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +# Government retains certain rights in this software. +# This software is distributed under the Revised BSD License. +# ___________________________________________________________________________ + +from __future__ import annotations +from typing import TYPE_CHECKING +if TYPE_CHECKING: + from prescient.simulator.options import Options + from .data_provider import DataProvider + +valid_input_formats = ('rts-gmlc', + 'dat') + +def get_data_provider(options:Options) -> DataProvider: + if options.input_format == 'rts-gmlc': + from .providers.gmlc_data_provider import GmlcDataProvider + return GmlcDataProvider(options) + + elif options.input_format == 'dat': + from .providers.dat_data_provider import DatDataProvider + return DatDataProvider(options) + + else: + raise ValueError(f"Invalid input format: {options.input_format}") + return None