コード例 #1
0
ファイル: grobid_metadata.py プロジェクト: timholds/fatcat
 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))
コード例 #2
0
 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,
         ))
コード例 #3
0
ファイル: journal_metadata.py プロジェクト: cclauss/fatcat
 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,
         ))
コード例 #4
0
 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,
         ))
コード例 #5
0
 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,
             ))
コード例 #6
0
 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))
コード例 #7
0
ファイル: arxiv.py プロジェクト: timholds/fatcat
 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()
コード例 #8
0
ファイル: datacite.py プロジェクト: EdwardBetts/fatcat
 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))
コード例 #9
0
    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
コード例 #10
0
ファイル: dblp_container.py プロジェクト: luisdomin5/fatcat
 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)
コード例 #11
0
    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
コード例 #12
0
ファイル: delete_builtins.py プロジェクト: timholds/fatcat
# 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",
)
コード例 #13
0
ファイル: fixtures.py プロジェクト: cclauss/fatcat
def quick_eg(api_inst):
    eg = api_inst.create_editgroup(fatcat_openapi_client.Editgroup())
    return eg