def generate_user_task_json()

in source/client/python/api-v0.1/api/connector.py [0:0]


    def generate_user_task_json(self, tasks_list=None):
        """this methods returns from a list of tasks, a tasks object that can be submitted to the grid

        Args:
          tasks_list (list): the list of tasks to submit (Default value = [])

        Returns:
          dict: an object that can be submitted to the grid

        """

        time_start_ms = int(round(time.time() * 1000))

        session_id = "None"

        binary_tasks_list = []

        if self.__task_input_passed_via_external_storage == 1:

            session_id = get_safe_session_id()
            logging.info("Local session id: {}".format(session_id))

            for i, data in enumerate(tasks_list):
                task_id = session_id + "_" + str(i)

                data = json.dumps(data).encode('utf-8')

                b64data = base64.b64encode(data)

                self.in_out_manager.put_input_from_bytes(task_id, b64data)

                # We are no longer passing the actual task definition
                binary_tasks_list.append(task_id)

        # creation message with tasks_list
        user_task_json = {
            "session_id": session_id,
            "scheduler_data": {
                "task_timeout_sec": TASK_TIMEOUT_SEC,
                "retry_count": RETRY_COUNT,
                "tstamp_api_grid_connector_ms": 0,
                "tstamp_agent_read_from_sqs_ms": 0
            },
            "stats": {
                "stage1_grid_api_01_task_creation_tstmp": {"label": " ", "tstmp": time_start_ms},
                "stage1_grid_api_02_task_submission_tstmp": {"label": "upload_data_to_storage",
                                                             "tstmp": int(round(time.time() * 1000))},

                "stage2_sbmtlmba_01_invocation_tstmp": {"label": "grid_api_2_lambda_ms", "tstmp": 0},
                "stage2_sbmtlmba_02_before_batch_write_tstmp": {"label": "task_construction_ms", "tstmp": 0},
                # "stage2_sbmtlmba_03_invocation_over_tstmp":    {"label": "dynamo_db_submit_ms", "tstmp" : 0},

                "stage3_agent_01_task_acquired_sqs_tstmp": {"label": "sqs_queuing_time_ms", "tstmp": 0},
                "stage3_agent_02_task_acquired_ddb_tstmp": {"label": "ddb_task_claiming_time_ms", "tstmp": 0},

                "stage4_agent_01_user_code_finished_tstmp": {"label": "user_code_exec_time_ms", "tstmp": 0},
                "stage4_agent_02_S3_stdout_delivered_tstmp": {"label": "S3_stdout_upload_time_ms", "tstmp": 0}
            },
            "tasks_list": {
                "tasks": binary_tasks_list if self.__task_input_passed_via_external_storage == 1 else tasks_list
            }
        }

        return user_task_json