def insert_batch(self, batch): self.api.create_file_auto_batch( fatcat_openapi_client.FileAutoBatch( editgroup=fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra), entity_list=batch))
def insert_batch(self, batch: List[FilesetEntity]) -> None: self.api.create_fileset_auto_batch( fatcat_openapi_client.FilesetAutoBatch( editgroup=fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra), entity_list=batch, ))
def insert_batch(self, batch: List[ContainerEntity]) -> None: self.api.create_container_auto_batch( fatcat_openapi_client.ContainerAutoBatch( editgroup=fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra), entity_list=batch, ))
def insert_batch(self, batch: List[ReleaseEntity]) -> None: self.api.create_release_auto_batch( fatcat_openapi_client.ReleaseAutoBatch( editgroup=fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra), entity_list=batch, ))
def insert_batch(self, batch: List[FilesetEntity]) -> None: if self.submit_mode: eg = self.api.create_editgroup( fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra)) for fe in batch: self.api.create_fileset(eg.editgroup_id, fe) self.api.update_editgroup(eg.editgroup_id, eg, submit=True) else: self.api.create_fileset_auto_batch( fatcat_openapi_client.FilesetAutoBatch( editgroup=fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra), entity_list=batch, ))
def insert_batch(self, batch): """ Usually running in submit_mode, so we can't use auto_batch method """ if self.submit_mode: eg = self.api.create_editgroup( fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra)) for fe in batch: self.api.create_file(eg.editgroup_id, fe) self.api.update_editgroup(eg.editgroup_id, eg, submit=True) else: self.api.create_file_auto_batch( fatcat_openapi_client.FileAutoBatch( editgroup=fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra), entity_list=batch))
def insert_batch(self, batch_batch): # there is no batch/bezerk mode for arxiv importer, except for testing if self._test_override: for batch in batch_batch: self.api.create_release_auto_batch(fatcat_openapi_client.ReleaseAutoBatch( editgroup=fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra), entity_list=batch)) self.counts['insert'] += len(batch) - 1 else: raise NotImplementedError()
def insert_batch(self, batch): print('inserting batch ({})'.format(len(batch)), file=sys.stderr) if self.insert_log_file: with open(self.insert_log_file, 'a') as f: for doc in batch: json.dump(entity_to_dict(doc, api_client=None), f) f.write('\n') self.api.create_release_auto_batch( fatcat_openapi_client.ReleaseAutoBatch( editgroup=fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra), entity_list=batch))
def get_editgroup_id(self, _edits: int = 1) -> str: """ This version of get_editgroup_id() is similar to the EntityImporter version, but does not update self._edit_count or submit editgroups. The edits parameter is ignored. """ if not self._editgroup_id: eg = self.api.create_editgroup( fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra)) self._editgroup_id = eg.editgroup_id assert self._editgroup_id return self._editgroup_id
def insert_batch(self, batch): """ Because we want to print a prefix/container_id match for each row, we require a special batch insert method """ eg = self.api.create_container_auto_batch( fatcat_openapi_client.ContainerAutoBatch( editgroup=fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra), entity_list=batch)) for c_edit in eg.edits.containers: c = self.api.get_container(c_edit.ident) print("\t".join([c.extra['dblp']['prefix'], c.ident]), file=self.dblp_container_map_output)
def get_editgroup_id(self, edits=1): if self._edit_count >= self.edit_batch_size: self.api.accept_editgroup(self._editgroup_id) self._editgroup_id = None self._edit_count = 0 self._edits_inflight = [] if not self._editgroup_id: eg = self.api.create_editgroup( fatcat_openapi_client.Editgroup( description=self.editgroup_description, extra=self.editgroup_extra)) self._editgroup_id = eg.editgroup_id self._edit_count += edits return self._editgroup_id
# cp ../extra/demo_entities/delete_builtins.py . # pipenv run python3 delete_builtins.py import fatcat_openapi_client from fatcat_tools import * import os token = os.environ['FATCAT_API_AUTH_TOKEN'] assert token api = authenticated_api('http://localhost:9411/v0', token) eg = api.create_editgroup(fatcat_openapi_client.Editgroup( description="Clear out built-in database example entities")) container_ids = ( "aaaaaaaaaaaaaeiraaaaaaaaae", "aaaaaaaaaaaaaeiraaaaaaaaai", "aaaaaaaaaaaaaeiraaaaaaaaam", ) creator_ids = ( "aaaaaaaaaaaaaircaaaaaaaaae", "aaaaaaaaaaaaaircaaaaaaaaai", "aaaaaaaaaaaaaircaaaaaaaaam", #"aaaaaaaaaaaaaircaaaaaaaaaq", ) file_ids = ( "aaaaaaaaaaaaamztaaaaaaaaae", "aaaaaaaaaaaaamztaaaaaaaaai", "aaaaaaaaaaaaamztaaaaaaaaam", )
def quick_eg(api_inst): eg = api_inst.create_editgroup(fatcat_openapi_client.Editgroup()) return eg