def create_resources(resources, tags=None): created_resources = [] cwd = os.getcwd() for r in resources: resource_name = r['id'] args = r.get('values', {}) node = r.get('location', None) values_from = r.get('values_from') from_path = r.get('from', None) tags = r.get('tags', []) base_path = os.path.join(cwd, from_path) new_resources = create(resource_name, base_path, args=args, tags=tags) created_resources += new_resources if not is_virtual(base_path): if node: node = load_resource(node) r = new_resources[0] node.connect(r, mapping={}) r.add_tags('location={}'.format(node.name)) update_inputs(resource_name, args) if values_from: from_resource = load_resource(values_from) from_resource.connect_with_events(r, use_defaults=False) return created_resources
def update_inputs(child, args): child = load_resource(child) connections, assignments = parse_inputs(args) for c in connections: mapping = {} parent = load_resource(c['parent']) events = c['events'] mapping[c['parent_input']] = c['child_input'] signals.connect(parent, child, mapping, events) child.update(assignments)
def update_inputs(child, args): child = load_resource(child) connections, assignments = parse_inputs(args) for c in connections: mapping = {} parent = load_resource(c['parent']) events = c['events'] use_defaults = not c['events'] is False mapping[c['parent_input']] = c['child_input'] parent.connect_with_events( child, mapping, events, use_defaults=use_defaults) child.update(assignments)
def update_inputs(child, args): child = load_resource(child) connections, assignments = parse_inputs(args) for c in connections: mapping = {} parent = load_resource(c['parent']) events = c['events'] use_defaults = not c['events'] is False mapping[c['parent_input']] = c['child_input'] parent.connect_with_events(child, mapping, events, use_defaults=use_defaults) child.update(assignments)
def update_inputs(child, args): child = load_resource(child) connections, assignments = parse_inputs(args) parents = defaultdict(lambda: defaultdict(dict)) for c in connections: mapping = {c["parent_input"]: c["child_input"]} parents[c["parent"]]["mapping"].update(mapping) if parents[c["parent"]].get("events", None) is None: parents[c["parent"]]["events"] = c["events"] for parent, data in parents.iteritems(): parent = load_resource(parent) use_defaults = not data["events"] is False mapping = data["mapping"] parent.connect_with_events(child, mapping, {}, use_defaults=use_defaults) child.update(assignments)
def update_inputs(child, args): child = load_resource(child) connections, assignments = parse_inputs(args) parents = defaultdict(lambda: defaultdict(dict)) for c in connections: mapping = {c['parent_input']: c['child_input']} parents[c['parent']]['mapping'].update(mapping) if parents[c['parent']].get('events', None) is None: parents[c['parent']]['events'] = c['events'] for parent, data in parents.iteritems(): parent = load_resource(parent) use_defaults = not data['events'] is False mapping = data['mapping'] parent.connect_with_events( child, mapping, {}, use_defaults=use_defaults) child.update(assignments)
def update_inputs(child, inputs): child = load_resource(child) connections, assignments, computable = parse_inputs(inputs) parents = defaultdict(lambda: defaultdict(dict)) for c in connections: mapping = {c['parent_input']: c['child_input']} parents[c['parent']]['mapping'].update(mapping) if parents[c['parent']].get('events', None) is None: parents[c['parent']]['events'] = c['events'] for parent, data in parents.iteritems(): parent = load_resource(parent) use_defaults = not data['events'] is False mapping = data['mapping'] parent.connect_with_events( child, mapping, {}, use_defaults=use_defaults) child.update(assignments) for comp in computable: child.input_computable_change(**comp)
def create_resources(base_path, resources, tags=None): add_tags = tags created_resources = [] for r in resources: resource_name = r['id'] inputs = r.get('input', {}) node = r.get('location', None) values_from = r.get('values_from') spec = r.get('from', None) tags = r.get('tags', []) if add_tags: tags.extend(add_tags) is_composer_file = False if spec.startswith('./') or spec.endswith('.yaml'): spec = os.path.join(base_path, '..', spec) spec = os.path.abspath(os.path.normpath(spec)) is_composer_file = True new_resources = create(resource_name, spec, inputs=inputs, tags=tags) created_resources += new_resources if not spec.startswith('/'): repo, parsed_spec = Repository.parse(spec) is_composer_file = repo.is_composer_file(spec) if not is_composer_file: if node: node = load_resource(node) r = new_resources[0] node.connect(r, mapping={}) r.add_tags('location={}'.format(node.name)) update_inputs(resource_name, inputs) if values_from: from_resource = load_resource(values_from) from_resource.connect_with_events(r, use_defaults=False) return created_resources
def update_inputs(child, inputs): child = load_resource(child) connections, assignments, computable = parse_inputs(inputs) parents = defaultdict(lambda: defaultdict(dict)) for c in connections: if not parents[c['parent']]['mapping'].get(c['parent_input']): parents[c['parent']]['mapping'][c['parent_input']] = [] mapping = parents[c['parent']]['mapping'] mapping[c['parent_input']].append(c['child_input']) if parents[c['parent']].get('events', None) is None: parents[c['parent']]['events'] = c['events'] for parent, data in parents.iteritems(): parent = load_resource(parent) use_defaults = not data['events'] is False mapping = data['mapping'] parent.connect_with_events( child, mapping, {}, use_defaults=use_defaults) child.update(assignments) for comp in computable: child.input_computable_change(**comp)
def create_resources(resources, tags=None): created_resources = [] cwd = os.getcwd() for r in resources: resource_name = r['id'] args = r.get('values', {}) node = r.get('location', None) from_path = r.get('from', None) tags = r.get('tags', []) base_path = os.path.join(cwd, from_path) new_resources = create(resource_name, base_path, args=args, tags=tags) created_resources += new_resources if not is_virtual(base_path): if node: node = load_resource(node) r = new_resources[0] signals.connect(node, r, {}) r.add_tags('location={}'.format(node.name)) update_inputs(resource_name, args) return created_resources
def create_resources(resources, tags=None): created_resources = [] cwd = os.getcwd() for r in resources: resource_name = r["id"] args = r.get("values", {}) node = r.get("location", None) from_path = r.get("from", None) tags = r.get("tags", []) base_path = os.path.join(cwd, from_path) new_resources = create(resource_name, base_path, args=args, tags=tags) created_resources += new_resources if not is_virtual(base_path): if node: node = load_resource(node) r = new_resources[0] node.connect(r, mapping={}) r.add_tags("location={}".format(node.name)) update_inputs(resource_name, args) return created_resources