def clause_to_subset(traverser, graph, clause): """Take a selection query and return a list of the selected and qualified items. Args: graph (Dict[str, Dict[str, Set[str]]]): the input and output dependency graph. clause (str): the subselection query in model selection syntax, e.g. "*some_solid+" will select all of some_solid's upstream dependencies and its direct downstream dependecies. Returns: subset_list (List[str]): a list of selected and qualified solid names, empty if input is invalid. """ # parse cluase if not is_str(clause): return [] parts = parse_clause(clause) if parts is None: return [] up_depth, item_name, down_depth = parts # item_name invalid if item_name not in graph["upstream"]: return [] subset_list = [] traverser = Traverser(graph=graph) subset_list.append(item_name) # traverse graph to get up/downsteam items subset_list += traverser.fetch_upstream(item_name, up_depth) subset_list += traverser.fetch_downstream(item_name, down_depth) return subset_list
def get_solid_selection_from_args(kwargs): solid_selection_str = kwargs.get("solid_selection") if not is_str(solid_selection_str): return None return [ele.strip() for ele in solid_selection_str.split(",") ] if solid_selection_str else None
def __new__(cls, asset_key, description=None, metadata_entries=None, partition=None): if isinstance(asset_key, AssetKey): check.inst_param(asset_key, "asset_key", AssetKey) elif is_str(asset_key): asset_key = AssetKey(parse_asset_key_string(asset_key)) elif isinstance(asset_key, list): check.is_list(asset_key, of_type=str) asset_key = AssetKey(asset_key) else: check.is_tuple(asset_key, of_type=str) asset_key = AssetKey(asset_key) return super(AssetMaterialization, cls).__new__( cls, asset_key=asset_key, description=check.opt_str_param(description, "description"), metadata_entries=check.opt_list_param(metadata_entries, metadata_entries, of_type=EventMetadataEntry), partition=check.opt_str_param(partition, "partition"), )
def validate_tags(tags): valid_tags = {} for key, value in check.opt_dict_param(tags, "tags", key_type=str).items(): if not is_str(value): valid = False err_reason = 'Could not JSON encode value "{}"'.format(value) try: str_val = seven.json.dumps(value) err_reason = 'JSON encoding "{json}" of value "{val}" is not equivalent to original value'.format( json=str_val, val=value) valid = seven.json.loads(str_val) == value except Exception: # pylint: disable=broad-except pass if not valid: raise DagsterInvalidDefinitionError( 'Invalid value for tag "{key}", {err_reason}. Tag values must be strings ' "or meet the constraint that json.loads(json.dumps(value)) == value." .format(key=key, err_reason=err_reason)) valid_tags[key] = str_val else: valid_tags[key] = value return frozentags(valid_tags)
def __new__( cls, label=None, description=None, metadata_entries=None, asset_key=None, partition=None, skip_deprecation_warning=False, ): if asset_key and is_str(asset_key): asset_key = AssetKey(parse_asset_key_string(asset_key)) else: check.opt_inst_param(asset_key, "asset_key", AssetKey) if not label: check.param_invariant( asset_key and asset_key.path, "label", "Either label or asset_key with a path must be provided", ) label = asset_key.to_string() if not skip_deprecation_warning: warnings.warn("`Materialization` is deprecated; use `AssetMaterialization` instead.") return super(Materialization, cls).__new__( cls, label=check.str_param(label, "label"), description=check.opt_str_param(description, "description"), metadata_entries=check.opt_list_param( metadata_entries, metadata_entries, of_type=EventMetadataEntry ), asset_key=asset_key, partition=check.opt_str_param(partition, "partition"), )
def __new__(cls, path=None): if is_str(path): path = [path] elif isinstance(path, list): path = check.list_param(path, "path", of_type=str) else: path = check.tuple_param(path, "path", of_type=str) return super(AssetKey, cls).__new__(cls, path=path)
def __new__(cls, path=None): if is_str(path): path = [validate_asset_key_string(path)] elif isinstance(path, list): path = validate_structured_asset_key( check.list_param(path, "path", of_type=str)) else: path = validate_structured_asset_key( check.tuple_param(path, "path", of_type=str)) return super(AssetKey, cls).__new__(cls, path=path)