def import_jobs(self, **kwargs: Any) -> None: jobs = kwargs["jobs_to_import"] path = self.path / "projects" / "exported_jobs" for file in scandir(path / "services"): if file.name == ".gitkeep" or file.name not in jobs: continue with open(file.path, "r") as instance_file: instance = yaml.load(instance_file) model = instance.pop("type") factory(model, **self.objectify(model, instance)) Session.commit() for workflow in listdir(path / "workflows"): if workflow == ".gitkeep" or workflow not in jobs: continue workflow_name = workflow.split(".")[0] with open_tar(path / "workflows" / workflow) as tar_file: tar_file.extractall(path=path / "workflows") for instance_type in ("jobs", "workflow", "edges"): path_job = path / "workflows" / workflow_name / instance_type for file in scandir(path_job): with open(path_job / file.name, "r") as instance_file: instance = yaml.load(instance_file) if instance_type == "workflow": delete("Workflow", allow_none=True, name=instance["name"]) Session.commit() model = instance.pop("type") factory(model, **self.objectify(model, instance)) Session.commit() rmtree(path / "workflows" / workflow_name)
def delete_node(self, workflow_id, service_id): workflow, service = ( fetch("workflow", id=workflow_id), fetch("service", id=service_id), ) workflow.services.remove(service) if not service.shared: delete("service", id=service.id) now = self.get_time() workflow.last_modified = now return {"service": service.serialized, "update_time": now}
def delete_edge(self, workflow_id: int, edge_id: int) -> str: delete("WorkflowEdge", id=edge_id) now = self.get_time() fetch("Workflow", id=workflow_id).last_modified = now return now
def delete(self, cls: str, name: str) -> dict: result = delete(cls, name=name) Session.commit() return result
def delete_instance(self, instance_type, instance_id): return delete(instance_type, id=instance_id)
def delete(self): for service in self.services: if not service.shared: delete("service", id=service.id)
def delete_edge(self, workflow_id, edge_id): delete("workflow_edge", id=edge_id) now = self.get_time() fetch("workflow", id=workflow_id).last_modified = now return now
def delete_instance(self, cls, instance_id): return delete(cls, id=instance_id)
def cli_delete(table: str, name: str) -> None: device = delete(table, name=name) Session.commit() echo(controller.str_dict(device))
def delete_instance(self, cls: str, instance_id: int) -> dict: return delete(cls, id=instance_id)
def cli_delete(table, name): device = delete(table, name=name) Session.commit() echo(app.str_dict(device))
def delete(self, cls, name): result = delete(cls, name=name) Session.commit() return result