def load_entities(self): # To potentially save time, sanity check if entities already exist r1 = fapi.get_entity(self.project, self.workspace, "sample_set", "SS-TP") r2 = fapi.get_entity(self.project, self.workspace, "participant_set", "PARTICIP_SET_2") if r1.status_code == 200 and r2.status_code == 200: return if r1.status_code not in [404, 200 ] or r2.status_code not in [404, 200]: raise RuntimeError("while checking for sample_set/participant_set") print("\n\tLoading data entities for tests ...", file=sys.stderr) args = ("entity_import", "-p", self.project, "-w", self.workspace) datapath = os.path.join("firecloud", "tests") call_func(*(args + ("-f", os.path.join(datapath, "participants.tsv")))) call_func( *(args + ("-f", os.path.join(datapath, "particip_set_members.tsv")))) call_func(*(args + ("-f", os.path.join(datapath, "particip_set.tsv")))) call_func(*(args + ("-f", os.path.join(datapath, "samples.tsv")))) call_func(*(args + ("-f", os.path.join(datapath, "sset_membership.tsv")))) call_func(*(args + ("-f", os.path.join(datapath, "sset.tsv")))) call_func(*(args + ("-f", os.path.join(datapath, "pairs.tsv")))) call_func(*(args + ("-f", os.path.join(datapath, "pairset_membership.tsv")))) call_func(*(args + ("-f", os.path.join(datapath, "pairset_attr.tsv")))) print("\t... done loading data ...", file=sys.stderr)
def load_entities(self): # To potentially save time, check if entities already exist r = fapi.get_entity(self.project, self.workspace, "sample_set", "SS-NT") if r.status_code == 200: return if r.status_code != 404: raise RuntimeError("while determining if SS-NT sample_set exists") call_func("entity_import", "-p", self.project, "-w", self.workspace, "-f", os.path.join("firecloud", "tests", "participants.tsv")) call_func("entity_import", "-p", self.project, "-w", self.workspace, "-f", os.path.join("firecloud", "tests", "samples.tsv")) call_func("entity_import", "-p", self.project, "-w", self.workspace, "-f", os.path.join("firecloud", "tests", "sset_membership.tsv")) call_func("entity_import", "-p", self.project, "-w", self.workspace, "-f", os.path.join("firecloud", "tests", "sset.tsv")) call_func("entity_import", "-p", self.project, "-w", self.workspace, "-f", os.path.join("firecloud", "tests", "pairs.tsv")) call_func("entity_import", "-p", self.project, "-w", self.workspace, "-f", os.path.join("firecloud", "tests", "pairset_membership.tsv")) call_func("entity_import", "-p", self.project, "-w", self.workspace, "-f", os.path.join("firecloud", "tests", "pairset_attr.tsv"))
def get_entity(self, etype, entity_id): """Return entity in this workspace. Args: etype (str): Entity type entity_id (str): Entity name/unique id """ r = fapi.get_entity(self.namespace, self.name, etype, entity_id, self.api_url) fapi._check_response_code(r, 200) dresp = r.json() return Entity(etype, entity_id, dresp['attributes'])