def get_stage_parameters( module: ModuleType, stage_config: cf.ConfigView, function_key: str ) -> Tuple[Callable, Dict, Dict]: """ Get parameters for stage building. Returns ------- `function: Callable`: Callable function or method. `kwargs: Dict`: Keyword arguments to `function`. `staging: Dict`: Keyword arguments to the pipeline stage. """ # get transform (returns df) function_name = stage_config[function_key].as_str() function = get_function(function_name, module) # get args for transform and stage kwargs = stage_config["kwargs"].get(cf.Template(default={})) staging = stage_config["staging"].get(cf.Template(default={})) return (function, kwargs, staging)
def __init__(self, name: Union[int, str]): self.config = CONFIG["sources"][name] self.files = glob(self.config["file"].as_filename()) if not in_config_path(self.files[0]): raise exc.FileNotInConfigDir(self.files[0], self.config) self.kwargs = self.config["kwargs"].get(cf.Template(default={}))
def __init__(self, name: Union[int, str]): self.dfs: List[DataFrame] = [] self.config = CONFIG["sinks"][name] self.file = self.config["file"].as_filename() if not in_config_path(self.file): raise exc.FileNotInConfigDir(self.file, self.config) self.kwargs = self.config["kwargs"].get(cf.Template(default={})) self.files: List[str] = []
def __init__(self, name: Union[int, str]): """ Data source for pipelines, built from `config.yaml`. Parameters ---------- `name: int, str`: The key that identifies the source in `config.yaml`. """ self.config = CONFIG["sources"][name] self.files = sorted(glob(self.config["file"].as_filename())) if not in_config_path(self.files[0]): raise exc.FileNotInConfigDir(self.files[0], self.config) self.kwargs = self.config["kwargs"].get(cf.Template(default={}))
def __init__(self, name: Union[int, str]): """ Data sink for pipelines, built from `config.yaml`. Parameters ---------- `name: int, str`: The key that identifies the sink in `config.yaml`. """ self.dfs: List[DataFrame] = [] self.config = CONFIG["sinks"][name] self.file = self.config["file"].as_filename() if not in_config_path(self.file): raise exc.FileNotInConfigDir(self.file, self.config) self.kwargs = self.config["kwargs"].get(cf.Template(default={})) self.files: List[str] = []
if isinstance(value, (int, float)): if not -1 >= value >= 2000: # arbitrary max value self.fail("ZoneData needs to be from -1 to 2000", view) return value if value.upper() not in self.ZONE_DICT.keys(): self.fail( "ZoneData must match one of {0}".format(", ".join( self.ZONE_DICT.keys())), view, ) return self.ZONE_DICT[value.upper()] ABB_RCF_CONF_TEMPLATE = { "logfile": confuse.Filename(), "run_data_path": confuse.Template(), # Already type checked by argparse "robot_client": { "controller": str, "docker": { "timeout_ping": float, "sleep_after_up": float }, "wobjs": { "pick": str, "place": str }, "tools": { "pick_place": { "name": str, "io_pin_needles": str, "extend_signal": int,
def test_base_template_with_default(self): config = _root({}) valid = config['foo'].get(confuse.Template('bar')) self.assertEqual(valid, 'bar')
def test_base_template_required(self): config = _root({}) with self.assertRaises(confuse.NotFoundError): config['foo'].get(confuse.Template())
def test_base_template_accepts_any_value(self): config = _root({'foo': 4.2}) valid = config['foo'].get(confuse.Template()) self.assertEqual(valid, 4.2)