def save(self, user: User, commit=True): batch = super().save(commit) chunk_taric(self.files["taric_file"], batch) run_batch(batch=batch.name, username=user.username, status=self.data["status"]) return batch
def import_taric( taric3_file: str, username: str, status: str, partition_scheme_setting: str, name: str, split_codes: bool = False, dependencies=None, record_group: Sequence[str] = None, ): batch = setup_batch( batch_name=name, dependencies=dependencies, split_on_code=split_codes, ) with open(taric3_file, "rb") as seed_file: batch = chunk_taric(seed_file, batch, record_group=record_group) run_batch( batch.name, status, partition_scheme_setting, username, record_group=record_group, )
def import_taric( taric3_file, username, status, name, split_codes: bool = False, dependencies=None, ): batch = setup_batch( batch_name=name, dependencies=dependencies, split_on_code=split_codes, ) with open(taric3_file, "rb") as seed_file: batch = chunk_taric(seed_file, batch) run_batch(batch.name, status, username)
def save(self, user: User, commit=True): batch = super().save(commit) if self.data.get("commodities") is not None: record_group = TARIC_RECORD_GROUPS["commodities"] else: record_group = None chunk_taric(self.files["taric_file"], batch, record_group=record_group) run_batch( batch=batch.name, status=self.data["status"], partition_scheme_setting=settings.TRANSACTION_SCHEMA, username=user.username, record_group=record_group, ) return batch
def process_file( file, batch, user, record_group=TARIC_RECORD_GROUPS["commodities"], status=WorkflowStatus.EDITING, partition_scheme_setting=settings.TRANSACTION_SCHEMA, workbasket_id=None, ): chunk_taric(file, batch, record_group=record_group) run_batch( batch=batch.name, status=status, partition_scheme_setting=partition_scheme_setting, username=user.username, record_group=record_group, workbasket_id=workbasket_id, )
def save(self, user: User, workbasket_id: str, commit=True): # we don't ask the user to provide a name in the form so generate one here based on filename and timestamp now = datetime.now() current_time = now.strftime("%H%M%S") batch_name = f"{self.cleaned_data['taric_file'].name}_{current_time}" self.instance.name = batch_name batch = super().save(commit) record_group = TARIC_RECORD_GROUPS["commodities"] chunk_taric(self.cleaned_data["taric_file"], batch, record_group=record_group) run_batch( batch=batch.name, status=WorkflowStatus.EDITING, partition_scheme_setting=settings.TRANSACTION_SCHEMA, username=user.username, workbasket_id=workbasket_id, record_group=record_group, ) return batch