Skip to content

Commit

Permalink
input_data list: parent_task_idの取得方法を変更
Browse files Browse the repository at this point in the history
  • Loading branch information
yuji38kwmt committed Aug 6, 2019
1 parent ddf261b commit 47176a6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions annofabcli/input_data/list_input_data.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import argparse
import logging
import urllib.parse
from typing import Any, Callable, Dict, List, Optional, Tuple, Union # pylint: disable=unused-import

import annofabapi
import urllib.parse
from annofabapi.models import InputData, Task, TaskId

import annofabcli
Expand Down Expand Up @@ -53,15 +53,19 @@ def get_input_data(self, project_id: str, input_data_query: Dict[str, Any],
chunk_size = MAX_URL_QUERY_LENGTH // AVERAGE_INPUT_DATA_ID_LENGTH
initial_index = 0
while True:
sub_input_data_list = input_data_list[initial_index:initial_index+chunk_size]
sub_input_data_list = input_data_list[initial_index:initial_index + chunk_size]
sub_input_data_id_list = [e['input_data_id'] for e in sub_input_data_list]
str_input_data_id_list = ",".join(sub_input_data_id_list)
encoded_input_data_id_list = urllib.parse.quote(str_input_data_id_list)
if len(encoded_input_data_id_list) > MAX_URL_QUERY_LENGTH:
decreasing_size = (len(encoded_input_data_id_list) - MAX_URL_QUERY_LENGTH) // AVERAGE_INPUT_DATA_ID_LENGTH
differential_length = (len(encoded_input_data_id_list) - MAX_URL_QUERY_LENGTH)
decreasing_size = (differential_length // AVERAGE_INPUT_DATA_ID_LENGTH) + 1
logger.debug(f"chunk_sizeを {chunk_size} から、{chunk_size - decreasing_size} に減らした. "
f"len(encoded_input_data_id_list) = {len(encoded_input_data_id_list)}")
chunk_size = chunk_size - decreasing_size
if chunk_size <= 0:
chunk_size = 1

continue

logger.debug(f"input_data_list[{initial_index}:{initial_index+chunk_size}] を使用しているタスクを取得する。")
Expand All @@ -74,9 +78,9 @@ def get_input_data(self, project_id: str, input_data_query: Dict[str, Any],
task_id_list = self._find_task_id_list(task_list, input_data['input_data_id'])
self.visualize.add_properties_to_input_data(input_data, task_id_list)




initial_index = initial_index + chunk_size
if initial_index >= len(input_data_list):
break

for input_data_index, input_data in enumerate(input_data_list):
input_data_id = input_data['input_data_id']
Expand Down

0 comments on commit 47176a6

Please sign in to comment.