Ejemplo n.º 1
0
 def process_source(self, source, group_size=100):
     """Creates and auto-accepts editgroup every group_size rows"""
     eg = self.api.create_editgroup(
         fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae'))
     for i, row in enumerate(source):
         self.create_row(row, editgroup=eg.id)
         if i > 0 and (i % group_size) == 0:
             self.api.accept_editgroup(eg)
             eg = self.api.create_editgroup(
                 fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae'))
         self.processed_lines = self.processed_lines + 1
     if i == 0 or (i % group_size) != 0:
         self.api.accept_editgroup(eg.id)
Ejemplo n.º 2
0
 def create_batch(self, batch, editgroup=None):
     """Current work/release pairing disallows batch creation of releases.
     Could do batch work creation and then match against releases, but meh."""
     release_batch = []
     for row in batch:
         if row is None:
             continue
         obj = json.loads(row)
         entities = self.parse_crossref_dict(obj)
         if entities is not None:
             (re, ce) = entities
             if ce is not None:
                 ce_eg = self.api.create_editgroup(
                     fatcat_client.Editgroup(
                         editor_id='aaaaaaaaaaaabkvkaaaaaaaaae'))
                 container = self.api.create_container(ce,
                                                       editgroup=ce_eg.id)
                 self.api.accept_editgroup(ce_eg.id)
                 re.container_id = container.ident
                 self._issnl_id_map[ce.issnl] = container.ident
             release_batch.append(re)
     self.api.create_release_batch(release_batch,
                                   autoaccept="true",
                                   editgroup=editgroup)
     self.insert_count = self.insert_count + len(release_batch)
Ejemplo n.º 3
0
 def process_batch(self, source, size=50):
     """Reads and processes in batches (not API-call-per-)"""
     for rows in grouper(source, size):
         self.processed_lines = self.processed_lines + len(rows)
         eg = self.api.create_editgroup(
             fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae'))
         self.create_batch(rows, editgroup=eg.id)
Ejemplo n.º 4
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

        if not self._editgroup_id:
            eg = self.api.create_editgroup(
                fatcat_client.Editgroup(description=self.editgroup_description,
                                        extra=self.editgroup_extra))
            self._editgroup_id = eg.editgroup_id

        self._edit_count += edits
        return self._editgroup_id
Ejemplo n.º 5
0
def quick_eg(api_inst):
    eg = api_inst.create_editgroup(fatcat_client.Editgroup())
    return eg
Ejemplo n.º 6
0
# cp ../extra/demo_entities/delete_builtins.py .
# pipenv run python3 delete_builtins.py

import fatcat_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_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",
)