Context / Client / start_task

start_task

Context.Client.start_task(**kwargs)

Starts a task that imports a data dictionary, verified queries, or ontologies into an agent context. The task runs asynchronously and records the changes it makes as change sets. GetTask returns its status.

See also: AWS API Documentation

Request Syntax

response = client.start_task(
    agentContextId='string',
    clientToken='string',
    description='string',
    inputConfiguration={
        'importDataDictionary': {
            'documents': [
                {
                    'name': 'string',
                    'contentType': 'CSV'|'JSON'|'YAML'|'MARKDOWN'|'SQL'|'TXT',
                    'content': b'bytes'
                },
            ]
        },
        'importVerifiedQueries': {
            'documents': [
                {
                    'name': 'string',
                    'contentType': 'CSV'|'JSON'|'YAML'|'MARKDOWN'|'SQL'|'TXT',
                    'content': b'bytes'
                },
            ]
        },
        'importOntology': {
            'ontologies': [
                {
                    'ontologyId': 'string',
                    'ontologyVersion': 'string'
                },
            ]
        }
    },
    accessControlConfig={
        'accessControlList': [
            {
                'access': 'ALLOW'|'DENY',
                'principalId': 'string',
                'principalType': 'USER'|'GROUP'
            },
        ]
    }
)
Parameters:
  • agentContextId (string) –

    [REQUIRED]

    The agent context, as an ID or ARN.

  • clientToken (string) –

    A unique, case-sensitive identifier that you provide to ensure that the request completes no more than one time. The token is scoped to your account and the agent context. If you reuse a token on the same agent context with different parameters, the request fails with ValidationException.

    This field is autopopulated if not provided.

  • description (string) – A description of the task. Up to 1,024 characters, with no control characters.

  • inputConfiguration (dict) –

    [REQUIRED]

    What the task imports. Set exactly one member. The member that you set determines the task’s type.

    Note

    This is a Tagged Union structure. Only one of the following top level keys can be set: importDataDictionary, importVerifiedQueries, importOntology.

    • importDataDictionary (dict) –

      Imports a data dictionary into the agent context from documents of type CSV, JSON, YAML, or MARKDOWN. The task’s type is IMPORT_DATA_DICTIONARY.

      • documents (list) – [REQUIRED]

        The documents to import the data dictionary from, sent inline: 1–10 documents of type CSV, JSON, YAML, or MARKDOWN, with at most 10,485,760 bytes (10 MiB) of content in total.

        • (dict) –

          A document for a task to read, sent inline in the StartTask request.

          • name (string) – [REQUIRED]

            The name of the document. The name must be unique within the request.

          • contentType (string) – [REQUIRED]

            You must specify a content type that the task configuration accepts. Otherwise, the request fails with ValidationException.

          • content (bytes) – [REQUIRED]

            The content of the document. All the documents in one request can total at most 10,485,760 bytes (10 MiB).

    • importVerifiedQueries (dict) –

      Imports verified queries into the agent context from documents of type SQL, CSV, JSON, or TXT. The task’s type is IMPORT_VERIFIED_QUERIES.

      • documents (list) – [REQUIRED]

        The documents to import the verified queries from, sent inline: 1–10 documents of type SQL, CSV, JSON, or TXT, with at most 10,485,760 bytes (10 MiB) of content in total.

        • (dict) –

          A document for a task to read, sent inline in the StartTask request.

          • name (string) – [REQUIRED]

            The name of the document. The name must be unique within the request.

          • contentType (string) – [REQUIRED]

            You must specify a content type that the task configuration accepts. Otherwise, the request fails with ValidationException.

          • content (bytes) – [REQUIRED]

            The content of the document. All the documents in one request can total at most 10,485,760 bytes (10 MiB).

    • importOntology (dict) –

      Imports one or more ontologies into the agent context. The task’s type is IMPORT_ONTOLOGY.

      • ontologies (list) – [REQUIRED]

        The ontologies to import, in import order. Each ARN can appear only once.

        • (dict) –

          An ontology to import into the agent context, and optionally the version of it to import.

          • ontologyId (string) – [REQUIRED]

            An ontology ID or ARN, in the account that owns the agent context.

          • ontologyVersion (string) –

            The ontology version to import. If you omit it, the task imports the ontology’s default version at the time the import runs.

  • accessControlConfig (dict) –

    Who can see the content that the task adds to the agent context. AWS Context supports only one entry: ALLOW with principalId *, so that every reader of the agent context can see it. If you omit it or send no entries, AWS Context uses that entry. If you name any other principal, include a DENY entry, or send more than one entry, the request fails with ValidationException, and no task is started.

    • accessControlList (list) –

      Entries, each allowing or denying one principal.

      • (dict) –

        Allows or denies one end user or group, or every reader ( *).

        • access (string) – [REQUIRED]

          Specifies whether the principal can see the information.

          Valid values:

          • ALLOW - Access is allowed.

          • DENY - Access is denied.

        • principalId (string) – [REQUIRED]

          The principal’s opaque user or group ID, or * for every reader authorized on the resource.

        • principalType (string) –

          Specifies whether principalId names a user or a group. Required unless principalId is *, where it is ignored.

          Valid values:

          • USER - An end user.

          • GROUP - A group of end users.

Return type:

dict

Returns:

Response Syntax

{
    'id': 'string',
    'arn': 'string',
    'agentContextId': 'string',
    'type': 'IMPORT_DATA_DICTIONARY'|'IMPORT_VERIFIED_QUERIES'|'IMPORT_ONTOLOGY',
    'status': 'PENDING'|'IN_PROGRESS'|'COMPLETED'|'FAILED'|'CANCELLING'|'CANCELLED',
    'description': 'string',
    'createdAt': datetime(2015, 1, 1),
    'updatedAt': datetime(2015, 1, 1),
    'statusReasonCode': 'GRAPH_NOT_ACTIVE'|'ONTOLOGY_INVALID'|'ONTOLOGY_IMPORT_UNAVAILABLE'|'ONTOLOGY_ALREADY_IMPORTED',
    'statusMessage': 'string',
    'statistics': {
        'numberOfDocumentsAnalyzed': 123,
        'numberOfChangeSetsCreated': 123,
        'numberOfChangeSetsAutoApproved': 123
    },
    'inputConfiguration': {
        'importDataDictionary': {
            'documents': [
                {
                    'name': 'string',
                    'sizeBytes': 123,
                    'contentType': 'CSV'|'JSON'|'YAML'|'MARKDOWN'|'SQL'|'TXT'
                },
            ]
        },
        'importVerifiedQueries': {
            'documents': [
                {
                    'name': 'string',
                    'sizeBytes': 123,
                    'contentType': 'CSV'|'JSON'|'YAML'|'MARKDOWN'|'SQL'|'TXT'
                },
            ]
        },
        'importOntology': {
            'ontologies': [
                {
                    'ontologyArn': 'string',
                    'ontologyVersion': 'string'
                },
            ]
        }
    },
    'outputs': [
        {
            'changeSet': {
                'changeSetId': 'string'
            }
        },
    ]
}

Response Structure

  • (dict) –

    • id (string) –

      The ID of the task. Pass it as taskId to GetTask or CancelTask.

    • arn (string) –

      The Amazon Resource Name (ARN) of the task.

    • agentContextId (string) –

      The agent context’s ID.

    • type (string) –

      The type of the task. It is set by the inputConfiguration member that the task was started with: IMPORT_DATA_DICTIONARY, IMPORT_VERIFIED_QUERIES, or IMPORT_ONTOLOGY.

    • status (string) –

      The status of the task. A task moves from PENDING to IN_PROGRESS and ends COMPLETED, FAILED, or CANCELLED. After CancelTask, it is CANCELLING until it stops.

    • description (string) –

      The description of the task, as given to StartTask.

    • createdAt (datetime) –

      The date and time when the task was created.

    • updatedAt (datetime) –

      The date and time when the task was last updated, such as when its status changed. Equal to createdAt until the task first changes.

    • statusReasonCode (string) –

      The code for why the task failed. Present only when status is FAILED.

      Valid values:

      • GRAPH_NOT_ACTIVE - The agent context was deleted, or was not yet available, while the task ran.

      • ONTOLOGY_INVALID - An ontology is missing, has no loadable source, or its source is unsafe or too large.

      • ONTOLOGY_IMPORT_UNAVAILABLE - An ontology couldn’t be imported because of a temporary problem. Start a new task.

      • ONTOLOGY_ALREADY_IMPORTED - This ontology version is already imported into the agent context.

    • statusMessage (string) –

      The reason the task failed. Present only when status is FAILED.

    • statistics (dict) –

      Counts of the documents that the task analyzed and the change sets that it created. The counts are final once the task is COMPLETED, FAILED, or CANCELLED.

      • numberOfDocumentsAnalyzed (integer) –

        The number of input documents that the task has analyzed.

      • numberOfChangeSetsCreated (integer) –

        The number of change sets that the task has created.

      • numberOfChangeSetsAutoApproved (integer) –

        The number of change sets that the agent context’s curation policies published without review.

    • inputConfiguration (dict) –

      A summary of the input that the task was started with. Each document is returned as its name, size, and content type, not its content, and each ontology is returned as its ARN and, if set, its version.

      Note

      This is a Tagged Union structure. Only one of the following top level keys will be set: importDataDictionary, importVerifiedQueries, importOntology. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

      'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
      
      • importDataDictionary (dict) –

        The data dictionary documents that an IMPORT_DATA_DICTIONARY task was started with.

        • documents (list) –

          The names and sizes of the documents, in request order.

          • (dict) –

            The name, size, and content type of a document that a task was started with. The document’s content isn’t returned.

            • name (string) –

              The name of the document, as given in the StartTask request.

            • sizeBytes (integer) –

              The size of the document’s content, in bytes.

            • contentType (string) –

              The content type of the document, as declared in the StartTask request.

      • importVerifiedQueries (dict) –

        The verified query documents that an IMPORT_VERIFIED_QUERIES task was started with.

        • documents (list) –

          Names and sizes, in request order.

          • (dict) –

            The name, size, and content type of a document that a task was started with. The document’s content isn’t returned.

            • name (string) –

              The name of the document, as given in the StartTask request.

            • sizeBytes (integer) –

              The size of the document’s content, in bytes.

            • contentType (string) –

              The content type of the document, as declared in the StartTask request.

      • importOntology (dict) –

        The ontologies that an IMPORT_ONTOLOGY task was started with.

        • ontologies (list) –

          The ontologies that the task imports, in import order.

          • (dict) –

            An ontology that an IMPORT_ONTOLOGY task was started with, and the version that was requested.

            • ontologyArn (string) –

              The Amazon Resource Name (ARN) of the ontology to import.

            • ontologyVersion (string) –

              The ontology version, as requested. Absent if the request omitted it, in which case the task imported the default version at the time the import ran.

    • outputs (list) –

      What the task created, in creation order. Set when it finishes.

      • (dict) –

        One thing a task created: exactly one member.

        Note

        This is a Tagged Union structure. Only one of the following top level keys will be set: changeSet. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

        'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
        
        • changeSet (dict) –

          A change set that the task created. Pass its changeSetId to GetChangeSet to read it.

          • changeSetId (string) –

            The ID of a change set that the task created. Pass it to GetChangeSet to read the change set.

Exceptions

  • Context.Client.exceptions.ThrottlingException

  • Context.Client.exceptions.ConflictException

  • Context.Client.exceptions.ValidationException

  • Context.Client.exceptions.ServiceQuotaExceededException

  • Context.Client.exceptions.InternalServerException

  • Context.Client.exceptions.ResourceNotFoundException

  • Context.Client.exceptions.AccessDeniedException