Import Models#

This documentation auto-generates details about the Pydantic models defined in app/domain/imports/models/models.py.

Models used by the Import domain.

class app.domain.imports.models.models.CollisionStrategy(*values)[source]#

The strategy to use when an identifier collision is detected.

Identifier collisions are detected on identifier_type and identifier (and other_identifier_name where relevant) already present in the database.

Enhancement collisions are detected on an entry with matching enhancement_type and source already being present on the collided reference.

  • discard: Do nothing with the incoming reference.

  • fail: Do nothing with the incoming reference and mark it as failed. This allows the importing process to “follow up” on the failure.

  • merge_aggressive: Prioritize the incoming reference’s identifiers and enhancements in the merge.

  • merge_defensive: Prioritize the existing reference’s identifiers and enhancements in the merge.

  • append: Performs an aggressive merge of identifiers, and an append of enhancements.

  • overwrite: Performs an aggressive merge of identifiers, and an overwrite of enhancements (deleting existing and recreating what is imported). This should be used sparingly and carefully.

APPEND = 'append'[source]#
DISCARD = 'discard'[source]#
FAIL = 'fail'[source]#
MERGE_AGGRESSIVE = 'merge_aggressive'[source]#
MERGE_DEFENSIVE = 'merge_defensive'[source]#
OVERWRITE = 'overwrite'[source]#
pydantic model app.domain.imports.models.models.ImportBatch[source]#

Core import batch model with database and internal attributes included.

Show Entity Relationship Diagram
digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "app.domain.imports.models.models.ImportBatch"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ImportBatch</b></td></tr><tr><td>id</td><td port="id">UUID</td></tr><tr><td>collision_strategy</td><td port="collision_strategy">CollisionStrategy</td></tr><tr><td>storage_url</td><td port="storage_url">HttpUrl</td></tr><tr><td>callback_url</td><td port="callback_url">HttpUrl | None</td></tr><tr><td>status</td><td port="status">ImportBatchStatus</td></tr><tr><td>import_record_id</td><td port="import_record_id">UUID</td></tr><tr><td>import_record</td><td port="import_record">ImportRecord | None</td></tr><tr><td>import_results</td><td port="import_results">list[ImportResult] | None</td></tr></table>>,
      tooltip="app.domain.imports.models.models.ImportBatch&#xA;&#xA;Core import batch model with database and internal attributes included.&#xA;"];
   "app.domain.imports.models.models.ImportRecord"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ImportRecord</b></td></tr><tr><td>id</td><td port="id">UUID</td></tr><tr><td>search_string</td><td port="search_string">str | None</td></tr><tr><td>searched_at</td><td port="searched_at">PastDatetime</td></tr><tr><td>processor_name</td><td port="processor_name">str</td></tr><tr><td>processor_version</td><td port="processor_version">str</td></tr><tr><td>notes</td><td port="notes">str | None</td></tr><tr><td>expected_reference_count</td><td port="expected_reference_count">int</td></tr><tr><td>source_name</td><td port="source_name">str</td></tr><tr><td>status</td><td port="status">ImportRecordStatus</td></tr><tr><td>batches</td><td port="batches">list[ImportBatch] | None</td></tr></table>>,
      tooltip="app.domain.imports.models.models.ImportRecord&#xA;&#xA;Core import record model with database and internal attributes included.&#\
xA;"];
   "app.domain.imports.models.models.ImportBatch":import_record:e -> "app.domain.imports.models.models.ImportRecord":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "app.domain.imports.models.models.ImportResult"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ImportResult</b></td></tr><tr><td>id</td><td port="id">UUID</td></tr><tr><td>import_batch_id</td><td port="import_batch_id">UUID</td></tr><tr><td>status</td><td port="status">ImportResultStatus</td></tr><tr><td>import_batch</td><td port="import_batch">ImportBatch | None</td></tr><tr><td>reference_id</td><td port="reference_id">UUID | None</td></tr><tr><td>failure_details</td><td port="failure_details">str | None</td></tr></table>>,
      tooltip="app.domain.imports.models.models.ImportResult&#xA;&#xA;Core import result model with database attributes included.&#xA;"];
   "app.domain.imports.models.models.ImportBatch":import_results:e -> "app.domain.imports.models.models.ImportResult":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "app.domain.imports.models.models.ImportRecord":batches:e -> "app.domain.imports.models.models.ImportBatch":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "app.domain.imports.models.models.ImportResult":import_batch:e -> "app.domain.imports.models.models.ImportBatch":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
}

Show JSON schema
{
   "$defs": {
      "CollisionStrategy": {
         "description": "The strategy to use when an identifier collision is detected.\n\nIdentifier collisions are detected on ``identifier_type`` and ``identifier``\n(and ``other_identifier_name`` where relevant) already present in the database.\n\nEnhancement collisions are detected on an entry with matching ``enhancement_type``\nand ``source`` already being present on the collided reference.\n\n- `discard`: Do nothing with the incoming reference.\n- `fail`: Do nothing with the incoming reference and mark it as failed. This\n  allows the importing process to \"follow up\" on the failure.\n- `merge_aggressive`: Prioritize the incoming reference's identifiers and\n  enhancements in the merge.\n- `merge_defensive`: Prioritize the existing reference's identifiers and\n  enhancements in the merge.\n- `append`: Performs an aggressive merge of identifiers, and an append of\n  enhancements.\n- `overwrite`: Performs an aggressive merge of identifiers, and an overwrite of\n  enhancements (deleting existing and recreating what is imported). This should\n  be used sparingly and carefully.",
         "enum": [
            "discard",
            "fail",
            "merge_aggressive",
            "merge_defensive",
            "append",
            "overwrite"
         ],
         "title": "CollisionStrategy",
         "type": "string"
      },
      "ImportBatch": {
         "description": "Core import batch model with database and internal attributes included.",
         "properties": {
            "id": {
               "description": "The autogenerated database ID.",
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "collision_strategy": {
               "$ref": "#/$defs/CollisionStrategy",
               "default": "fail",
               "description": "\nThe strategy to use for each reference when an identifier collision occurs.\nDefault is `fail`, which allows the importing process to \"follow up\" on the collision.\n        "
            },
            "storage_url": {
               "description": "\nThe URL at which the set of references for this batch are stored.\n    ",
               "format": "uri",
               "maxLength": 2083,
               "minLength": 1,
               "title": "Storage Url",
               "type": "string"
            },
            "callback_url": {
               "anyOf": [
                  {
                     "format": "uri",
                     "maxLength": 2083,
                     "minLength": 1,
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "\nThe URL to which the processor should send a callback when the batch has been processed.\n        ",
               "title": "Callback Url"
            },
            "status": {
               "$ref": "#/$defs/ImportBatchStatus",
               "default": "created",
               "description": "The status of the batch."
            },
            "import_record_id": {
               "description": "The ID of the parent import record.",
               "format": "uuid",
               "title": "Import Record Id",
               "type": "string"
            },
            "import_record": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/ImportRecord"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The parent import record."
            },
            "import_results": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/ImportResult"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The results from processing the batch.",
               "title": "Import Results"
            }
         },
         "required": [
            "storage_url",
            "import_record_id"
         ],
         "title": "ImportBatch",
         "type": "object"
      },
      "ImportBatchStatus": {
         "description": "Describes the status of an import batch.\n\n- `created`: Created, but no processing has started.\n- `started`: Processing has started on the batch.\n- `failed`: Processing has failed.\n- `retrying`: Processing has failed, but is being retried.\n- `indexing`: The imports have been saved and are being indexed.\n- `indexing_failed`: The imports have been saved but were not indexed.\n- `completed`: Processing has been completed.\n- `cancelled`: Processing was cancelled by calling the API.",
         "enum": [
            "created",
            "started",
            "retrying",
            "failed",
            "indexing",
            "indexing_failed",
            "completed",
            "cancelled"
         ],
         "title": "ImportBatchStatus",
         "type": "string"
      },
      "ImportRecord": {
         "description": "Core import record model with database and internal attributes included.",
         "properties": {
            "id": {
               "description": "The autogenerated database ID.",
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "search_string": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The search string used to produce this import",
               "title": "Search String"
            },
            "searched_at": {
               "description": "\nThe timestamp (including timezone) at which the search which produced\nthis import was conducted. If no timezone is included, the timestamp\nis assumed to be in UTC.\n        ",
               "format": "date-time",
               "title": "Searched At",
               "type": "string"
            },
            "processor_name": {
               "description": "The name of the processor that is importing the data.",
               "title": "Processor Name",
               "type": "string"
            },
            "processor_version": {
               "description": "The version of the processor that is importing the data.",
               "title": "Processor Version",
               "type": "string"
            },
            "notes": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "\nAny additional notes regarding the import (eg. reason for importing, known\nissues).\n        ",
               "title": "Notes"
            },
            "expected_reference_count": {
               "description": "\nThe number of references expected to be included in this import.\n-1 is accepted if the number is unknown.\n",
               "minimum": -1,
               "title": "Expected Reference Count",
               "type": "integer"
            },
            "source_name": {
               "description": "The source of the reference being imported (eg. Open Alex)",
               "title": "Source Name",
               "type": "string"
            },
            "status": {
               "$ref": "#/$defs/ImportRecordStatus",
               "default": "created",
               "description": "The status of the upload."
            },
            "batches": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/ImportBatch"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The batches associated with this import.",
               "title": "Batches"
            }
         },
         "required": [
            "processor_name",
            "processor_version",
            "expected_reference_count",
            "source_name"
         ],
         "title": "ImportRecord",
         "type": "object"
      },
      "ImportRecordStatus": {
         "description": "Describes the status of an import record.\n\n- `created`: Created, but no processing has started.\n- `started`: Processing has started on the batch.\n- `completed`: Processing has been completed.\n- `cancelled`: Processing was cancelled by calling the API.",
         "enum": [
            "created",
            "started",
            "completed",
            "cancelled"
         ],
         "title": "ImportRecordStatus",
         "type": "string"
      },
      "ImportResult": {
         "description": "Core import result model with database attributes included.",
         "properties": {
            "id": {
               "description": "The autogenerated database ID.",
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "import_batch_id": {
               "description": "The ID of the parent import batch.",
               "format": "uuid",
               "title": "Import Batch Id",
               "type": "string"
            },
            "status": {
               "$ref": "#/$defs/ImportResultStatus",
               "default": "created",
               "description": "The status of the result."
            },
            "import_batch": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/ImportBatch"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The parent import batch."
            },
            "reference_id": {
               "anyOf": [
                  {
                     "format": "uuid",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The ID of the created reference.",
               "title": "Reference Id"
            },
            "failure_details": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Details of any failure that occurred during processing.",
               "title": "Failure Details"
            }
         },
         "required": [
            "import_batch_id"
         ],
         "title": "ImportResult",
         "type": "object"
      },
      "ImportResultStatus": {
         "description": "Describes the status of an import result.\n\n- `created`: Created, but no processing has started.\n- `started`: The reference is currently being processed.\n- `completed`: The reference has been created.\n- `partially_failed`: The reference was created but one or more enhancements or\n  identifiers failed to be added. See the result's `failure_details` field for\n  more information.\n- `failed`: The reference failed to be created. See the result's `failure_details`\n  field for more information.\n- `cancelled`: Processing was cancelled by calling the API.",
         "enum": [
            "created",
            "started",
            "completed",
            "cancelled",
            "partially_failed",
            "failed"
         ],
         "title": "ImportResultStatus",
         "type": "string"
      }
   },
   "$ref": "#/$defs/ImportBatch"
}

Config:
  • from_attributes: bool = True

Fields:
field callback_url: HttpUrl | None = None[source]#

The URL to which the processor should send a callback when the batch has been processed.

field collision_strategy: CollisionStrategy = CollisionStrategy.FAIL[source]#

The strategy to use for each reference when an identifier collision occurs. Default is fail, which allows the importing process to “follow up” on the collision.

field id: uuid.UUID [Optional][source]#

The autogenerated database ID.

field import_record: ImportRecord | None = None[source]#

The parent import record.

field import_record_id: UUID [Required][source]#

The ID of the parent import record.

field import_results: list[ImportResult] | None = None[source]#

The results from processing the batch.

field status: ImportBatchStatus = ImportBatchStatus.CREATED[source]#

The status of the batch.

field storage_url: HttpUrl [Required][source]#

The URL at which the set of references for this batch are stored.

async classmethod from_sdk(data: ImportBatchIn, import_record_id: UUID) Self[source]#

Create an ImportBatch from the SDK input model.

check_serializability() None[source]#

Check that incoming SDK model is json-serializable.

This should be called during all domain model conversions.

Raises:

ValidationError: If the model is not json-serializable.

async to_sdk() ImportBatchRead[source]#

Convert the ImportBatch to the SDK model.

async to_sdk_summary() ImportBatchSummary[source]#

Convert the ImportBatch to the SDK summary model.

class app.domain.imports.models.models.ImportBatchStatus(*values)[source]#

Describes the status of an import batch.

  • created: Created, but no processing has started.

  • started: Processing has started on the batch.

  • failed: Processing has failed.

  • retrying: Processing has failed, but is being retried.

  • indexing: The imports have been saved and are being indexed.

  • indexing_failed: The imports have been saved but were not indexed.

  • completed: Processing has been completed.

  • cancelled: Processing was cancelled by calling the API.

CANCELLED = 'cancelled'[source]#
COMPLETED = 'completed'[source]#
CREATED = 'created'[source]#
FAILED = 'failed'[source]#
INDEXING = 'indexing'[source]#
INDEXING_FAILED = 'indexing_failed'[source]#
RETRYING = 'retrying'[source]#
STARTED = 'started'[source]#
pydantic model app.domain.imports.models.models.ImportRecord[source]#

Core import record model with database and internal attributes included.

Show Entity Relationship Diagram
digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "app.domain.imports.models.models.ImportBatch"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ImportBatch</b></td></tr><tr><td>id</td><td port="id">UUID</td></tr><tr><td>collision_strategy</td><td port="collision_strategy">CollisionStrategy</td></tr><tr><td>storage_url</td><td port="storage_url">HttpUrl</td></tr><tr><td>callback_url</td><td port="callback_url">HttpUrl | None</td></tr><tr><td>status</td><td port="status">ImportBatchStatus</td></tr><tr><td>import_record_id</td><td port="import_record_id">UUID</td></tr><tr><td>import_record</td><td port="import_record">ImportRecord | None</td></tr><tr><td>import_results</td><td port="import_results">list[ImportResult] | None</td></tr></table>>,
      tooltip="app.domain.imports.models.models.ImportBatch&#xA;&#xA;Core import batch model with database and internal attributes included.&#xA;"];
   "app.domain.imports.models.models.ImportRecord"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ImportRecord</b></td></tr><tr><td>id</td><td port="id">UUID</td></tr><tr><td>search_string</td><td port="search_string">str | None</td></tr><tr><td>searched_at</td><td port="searched_at">PastDatetime</td></tr><tr><td>processor_name</td><td port="processor_name">str</td></tr><tr><td>processor_version</td><td port="processor_version">str</td></tr><tr><td>notes</td><td port="notes">str | None</td></tr><tr><td>expected_reference_count</td><td port="expected_reference_count">int</td></tr><tr><td>source_name</td><td port="source_name">str</td></tr><tr><td>status</td><td port="status">ImportRecordStatus</td></tr><tr><td>batches</td><td port="batches">list[ImportBatch] | None</td></tr></table>>,
      tooltip="app.domain.imports.models.models.ImportRecord&#xA;&#xA;Core import record model with database and internal attributes included.&#\
xA;"];
   "app.domain.imports.models.models.ImportBatch":import_record:e -> "app.domain.imports.models.models.ImportRecord":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "app.domain.imports.models.models.ImportResult"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ImportResult</b></td></tr><tr><td>id</td><td port="id">UUID</td></tr><tr><td>import_batch_id</td><td port="import_batch_id">UUID</td></tr><tr><td>status</td><td port="status">ImportResultStatus</td></tr><tr><td>import_batch</td><td port="import_batch">ImportBatch | None</td></tr><tr><td>reference_id</td><td port="reference_id">UUID | None</td></tr><tr><td>failure_details</td><td port="failure_details">str | None</td></tr></table>>,
      tooltip="app.domain.imports.models.models.ImportResult&#xA;&#xA;Core import result model with database attributes included.&#xA;"];
   "app.domain.imports.models.models.ImportBatch":import_results:e -> "app.domain.imports.models.models.ImportResult":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "app.domain.imports.models.models.ImportRecord":batches:e -> "app.domain.imports.models.models.ImportBatch":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "app.domain.imports.models.models.ImportResult":import_batch:e -> "app.domain.imports.models.models.ImportBatch":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
}

Show JSON schema
{
   "$defs": {
      "CollisionStrategy": {
         "description": "The strategy to use when an identifier collision is detected.\n\nIdentifier collisions are detected on ``identifier_type`` and ``identifier``\n(and ``other_identifier_name`` where relevant) already present in the database.\n\nEnhancement collisions are detected on an entry with matching ``enhancement_type``\nand ``source`` already being present on the collided reference.\n\n- `discard`: Do nothing with the incoming reference.\n- `fail`: Do nothing with the incoming reference and mark it as failed. This\n  allows the importing process to \"follow up\" on the failure.\n- `merge_aggressive`: Prioritize the incoming reference's identifiers and\n  enhancements in the merge.\n- `merge_defensive`: Prioritize the existing reference's identifiers and\n  enhancements in the merge.\n- `append`: Performs an aggressive merge of identifiers, and an append of\n  enhancements.\n- `overwrite`: Performs an aggressive merge of identifiers, and an overwrite of\n  enhancements (deleting existing and recreating what is imported). This should\n  be used sparingly and carefully.",
         "enum": [
            "discard",
            "fail",
            "merge_aggressive",
            "merge_defensive",
            "append",
            "overwrite"
         ],
         "title": "CollisionStrategy",
         "type": "string"
      },
      "ImportBatch": {
         "description": "Core import batch model with database and internal attributes included.",
         "properties": {
            "id": {
               "description": "The autogenerated database ID.",
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "collision_strategy": {
               "$ref": "#/$defs/CollisionStrategy",
               "default": "fail",
               "description": "\nThe strategy to use for each reference when an identifier collision occurs.\nDefault is `fail`, which allows the importing process to \"follow up\" on the collision.\n        "
            },
            "storage_url": {
               "description": "\nThe URL at which the set of references for this batch are stored.\n    ",
               "format": "uri",
               "maxLength": 2083,
               "minLength": 1,
               "title": "Storage Url",
               "type": "string"
            },
            "callback_url": {
               "anyOf": [
                  {
                     "format": "uri",
                     "maxLength": 2083,
                     "minLength": 1,
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "\nThe URL to which the processor should send a callback when the batch has been processed.\n        ",
               "title": "Callback Url"
            },
            "status": {
               "$ref": "#/$defs/ImportBatchStatus",
               "default": "created",
               "description": "The status of the batch."
            },
            "import_record_id": {
               "description": "The ID of the parent import record.",
               "format": "uuid",
               "title": "Import Record Id",
               "type": "string"
            },
            "import_record": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/ImportRecord"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The parent import record."
            },
            "import_results": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/ImportResult"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The results from processing the batch.",
               "title": "Import Results"
            }
         },
         "required": [
            "storage_url",
            "import_record_id"
         ],
         "title": "ImportBatch",
         "type": "object"
      },
      "ImportBatchStatus": {
         "description": "Describes the status of an import batch.\n\n- `created`: Created, but no processing has started.\n- `started`: Processing has started on the batch.\n- `failed`: Processing has failed.\n- `retrying`: Processing has failed, but is being retried.\n- `indexing`: The imports have been saved and are being indexed.\n- `indexing_failed`: The imports have been saved but were not indexed.\n- `completed`: Processing has been completed.\n- `cancelled`: Processing was cancelled by calling the API.",
         "enum": [
            "created",
            "started",
            "retrying",
            "failed",
            "indexing",
            "indexing_failed",
            "completed",
            "cancelled"
         ],
         "title": "ImportBatchStatus",
         "type": "string"
      },
      "ImportRecord": {
         "description": "Core import record model with database and internal attributes included.",
         "properties": {
            "id": {
               "description": "The autogenerated database ID.",
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "search_string": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The search string used to produce this import",
               "title": "Search String"
            },
            "searched_at": {
               "description": "\nThe timestamp (including timezone) at which the search which produced\nthis import was conducted. If no timezone is included, the timestamp\nis assumed to be in UTC.\n        ",
               "format": "date-time",
               "title": "Searched At",
               "type": "string"
            },
            "processor_name": {
               "description": "The name of the processor that is importing the data.",
               "title": "Processor Name",
               "type": "string"
            },
            "processor_version": {
               "description": "The version of the processor that is importing the data.",
               "title": "Processor Version",
               "type": "string"
            },
            "notes": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "\nAny additional notes regarding the import (eg. reason for importing, known\nissues).\n        ",
               "title": "Notes"
            },
            "expected_reference_count": {
               "description": "\nThe number of references expected to be included in this import.\n-1 is accepted if the number is unknown.\n",
               "minimum": -1,
               "title": "Expected Reference Count",
               "type": "integer"
            },
            "source_name": {
               "description": "The source of the reference being imported (eg. Open Alex)",
               "title": "Source Name",
               "type": "string"
            },
            "status": {
               "$ref": "#/$defs/ImportRecordStatus",
               "default": "created",
               "description": "The status of the upload."
            },
            "batches": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/ImportBatch"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The batches associated with this import.",
               "title": "Batches"
            }
         },
         "required": [
            "processor_name",
            "processor_version",
            "expected_reference_count",
            "source_name"
         ],
         "title": "ImportRecord",
         "type": "object"
      },
      "ImportRecordStatus": {
         "description": "Describes the status of an import record.\n\n- `created`: Created, but no processing has started.\n- `started`: Processing has started on the batch.\n- `completed`: Processing has been completed.\n- `cancelled`: Processing was cancelled by calling the API.",
         "enum": [
            "created",
            "started",
            "completed",
            "cancelled"
         ],
         "title": "ImportRecordStatus",
         "type": "string"
      },
      "ImportResult": {
         "description": "Core import result model with database attributes included.",
         "properties": {
            "id": {
               "description": "The autogenerated database ID.",
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "import_batch_id": {
               "description": "The ID of the parent import batch.",
               "format": "uuid",
               "title": "Import Batch Id",
               "type": "string"
            },
            "status": {
               "$ref": "#/$defs/ImportResultStatus",
               "default": "created",
               "description": "The status of the result."
            },
            "import_batch": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/ImportBatch"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The parent import batch."
            },
            "reference_id": {
               "anyOf": [
                  {
                     "format": "uuid",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The ID of the created reference.",
               "title": "Reference Id"
            },
            "failure_details": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Details of any failure that occurred during processing.",
               "title": "Failure Details"
            }
         },
         "required": [
            "import_batch_id"
         ],
         "title": "ImportResult",
         "type": "object"
      },
      "ImportResultStatus": {
         "description": "Describes the status of an import result.\n\n- `created`: Created, but no processing has started.\n- `started`: The reference is currently being processed.\n- `completed`: The reference has been created.\n- `partially_failed`: The reference was created but one or more enhancements or\n  identifiers failed to be added. See the result's `failure_details` field for\n  more information.\n- `failed`: The reference failed to be created. See the result's `failure_details`\n  field for more information.\n- `cancelled`: Processing was cancelled by calling the API.",
         "enum": [
            "created",
            "started",
            "completed",
            "cancelled",
            "partially_failed",
            "failed"
         ],
         "title": "ImportResultStatus",
         "type": "string"
      }
   },
   "$ref": "#/$defs/ImportRecord"
}

Config:
  • from_attributes: bool = True

Fields:
field batches: list[ImportBatch] | None = None[source]#

The batches associated with this import.

field expected_reference_count: int [Required][source]#

The number of references expected to be included in this import. -1 is accepted if the number is unknown.

Constraints:
  • ge = -1

field id: uuid.UUID [Optional][source]#

The autogenerated database ID.

field notes: str | None = None[source]#

Any additional notes regarding the import (eg. reason for importing, known issues).

field processor_name: str [Required][source]#

The name of the processor that is importing the data.

field processor_version: str [Required][source]#

The version of the processor that is importing the data.

field search_string: str | None = None[source]#

The search string used to produce this import

field searched_at: PastDatetime [Optional][source]#

The timestamp (including timezone) at which the search which produced this import was conducted. If no timezone is included, the timestamp is assumed to be in UTC.

field source_name: str [Required][source]#

The source of the reference being imported (eg. Open Alex)

field status: ImportRecordStatus = ImportRecordStatus.CREATED[source]#

The status of the upload.

async classmethod from_sdk(data: ImportRecordIn) Self[source]#

Create an ImportRecord from the SDK input model.

check_serializability() None[source]#

Check that incoming SDK model is json-serializable.

This should be called during all domain model conversions.

Raises:

ValidationError: If the model is not json-serializable.

async to_sdk() ImportRecordRead[source]#

Convert the ImportRecord to the SDK model.

class app.domain.imports.models.models.ImportRecordStatus(*values)[source]#

Describes the status of an import record.

  • created: Created, but no processing has started.

  • started: Processing has started on the batch.

  • completed: Processing has been completed.

  • cancelled: Processing was cancelled by calling the API.

CANCELLED = 'cancelled'[source]#
COMPLETED = 'completed'[source]#
CREATED = 'created'[source]#
STARTED = 'started'[source]#
pydantic model app.domain.imports.models.models.ImportResult[source]#

Core import result model with database attributes included.

Show Entity Relationship Diagram
digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "app.domain.imports.models.models.ImportBatch"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ImportBatch</b></td></tr><tr><td>id</td><td port="id">UUID</td></tr><tr><td>collision_strategy</td><td port="collision_strategy">CollisionStrategy</td></tr><tr><td>storage_url</td><td port="storage_url">HttpUrl</td></tr><tr><td>callback_url</td><td port="callback_url">HttpUrl | None</td></tr><tr><td>status</td><td port="status">ImportBatchStatus</td></tr><tr><td>import_record_id</td><td port="import_record_id">UUID</td></tr><tr><td>import_record</td><td port="import_record">ImportRecord | None</td></tr><tr><td>import_results</td><td port="import_results">list[ImportResult] | None</td></tr></table>>,
      tooltip="app.domain.imports.models.models.ImportBatch&#xA;&#xA;Core import batch model with database and internal attributes included.&#xA;"];
   "app.domain.imports.models.models.ImportRecord"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ImportRecord</b></td></tr><tr><td>id</td><td port="id">UUID</td></tr><tr><td>search_string</td><td port="search_string">str | None</td></tr><tr><td>searched_at</td><td port="searched_at">PastDatetime</td></tr><tr><td>processor_name</td><td port="processor_name">str</td></tr><tr><td>processor_version</td><td port="processor_version">str</td></tr><tr><td>notes</td><td port="notes">str | None</td></tr><tr><td>expected_reference_count</td><td port="expected_reference_count">int</td></tr><tr><td>source_name</td><td port="source_name">str</td></tr><tr><td>status</td><td port="status">ImportRecordStatus</td></tr><tr><td>batches</td><td port="batches">list[ImportBatch] | None</td></tr></table>>,
      tooltip="app.domain.imports.models.models.ImportRecord&#xA;&#xA;Core import record model with database and internal attributes included.&#\
xA;"];
   "app.domain.imports.models.models.ImportBatch":import_record:e -> "app.domain.imports.models.models.ImportRecord":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "app.domain.imports.models.models.ImportResult"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ImportResult</b></td></tr><tr><td>id</td><td port="id">UUID</td></tr><tr><td>import_batch_id</td><td port="import_batch_id">UUID</td></tr><tr><td>status</td><td port="status">ImportResultStatus</td></tr><tr><td>import_batch</td><td port="import_batch">ImportBatch | None</td></tr><tr><td>reference_id</td><td port="reference_id">UUID | None</td></tr><tr><td>failure_details</td><td port="failure_details">str | None</td></tr></table>>,
      tooltip="app.domain.imports.models.models.ImportResult&#xA;&#xA;Core import result model with database attributes included.&#xA;"];
   "app.domain.imports.models.models.ImportBatch":import_results:e -> "app.domain.imports.models.models.ImportResult":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "app.domain.imports.models.models.ImportRecord":batches:e -> "app.domain.imports.models.models.ImportBatch":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "app.domain.imports.models.models.ImportResult":import_batch:e -> "app.domain.imports.models.models.ImportBatch":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
}

Show JSON schema
{
   "$defs": {
      "CollisionStrategy": {
         "description": "The strategy to use when an identifier collision is detected.\n\nIdentifier collisions are detected on ``identifier_type`` and ``identifier``\n(and ``other_identifier_name`` where relevant) already present in the database.\n\nEnhancement collisions are detected on an entry with matching ``enhancement_type``\nand ``source`` already being present on the collided reference.\n\n- `discard`: Do nothing with the incoming reference.\n- `fail`: Do nothing with the incoming reference and mark it as failed. This\n  allows the importing process to \"follow up\" on the failure.\n- `merge_aggressive`: Prioritize the incoming reference's identifiers and\n  enhancements in the merge.\n- `merge_defensive`: Prioritize the existing reference's identifiers and\n  enhancements in the merge.\n- `append`: Performs an aggressive merge of identifiers, and an append of\n  enhancements.\n- `overwrite`: Performs an aggressive merge of identifiers, and an overwrite of\n  enhancements (deleting existing and recreating what is imported). This should\n  be used sparingly and carefully.",
         "enum": [
            "discard",
            "fail",
            "merge_aggressive",
            "merge_defensive",
            "append",
            "overwrite"
         ],
         "title": "CollisionStrategy",
         "type": "string"
      },
      "ImportBatch": {
         "description": "Core import batch model with database and internal attributes included.",
         "properties": {
            "id": {
               "description": "The autogenerated database ID.",
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "collision_strategy": {
               "$ref": "#/$defs/CollisionStrategy",
               "default": "fail",
               "description": "\nThe strategy to use for each reference when an identifier collision occurs.\nDefault is `fail`, which allows the importing process to \"follow up\" on the collision.\n        "
            },
            "storage_url": {
               "description": "\nThe URL at which the set of references for this batch are stored.\n    ",
               "format": "uri",
               "maxLength": 2083,
               "minLength": 1,
               "title": "Storage Url",
               "type": "string"
            },
            "callback_url": {
               "anyOf": [
                  {
                     "format": "uri",
                     "maxLength": 2083,
                     "minLength": 1,
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "\nThe URL to which the processor should send a callback when the batch has been processed.\n        ",
               "title": "Callback Url"
            },
            "status": {
               "$ref": "#/$defs/ImportBatchStatus",
               "default": "created",
               "description": "The status of the batch."
            },
            "import_record_id": {
               "description": "The ID of the parent import record.",
               "format": "uuid",
               "title": "Import Record Id",
               "type": "string"
            },
            "import_record": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/ImportRecord"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The parent import record."
            },
            "import_results": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/ImportResult"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The results from processing the batch.",
               "title": "Import Results"
            }
         },
         "required": [
            "storage_url",
            "import_record_id"
         ],
         "title": "ImportBatch",
         "type": "object"
      },
      "ImportBatchStatus": {
         "description": "Describes the status of an import batch.\n\n- `created`: Created, but no processing has started.\n- `started`: Processing has started on the batch.\n- `failed`: Processing has failed.\n- `retrying`: Processing has failed, but is being retried.\n- `indexing`: The imports have been saved and are being indexed.\n- `indexing_failed`: The imports have been saved but were not indexed.\n- `completed`: Processing has been completed.\n- `cancelled`: Processing was cancelled by calling the API.",
         "enum": [
            "created",
            "started",
            "retrying",
            "failed",
            "indexing",
            "indexing_failed",
            "completed",
            "cancelled"
         ],
         "title": "ImportBatchStatus",
         "type": "string"
      },
      "ImportRecord": {
         "description": "Core import record model with database and internal attributes included.",
         "properties": {
            "id": {
               "description": "The autogenerated database ID.",
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "search_string": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The search string used to produce this import",
               "title": "Search String"
            },
            "searched_at": {
               "description": "\nThe timestamp (including timezone) at which the search which produced\nthis import was conducted. If no timezone is included, the timestamp\nis assumed to be in UTC.\n        ",
               "format": "date-time",
               "title": "Searched At",
               "type": "string"
            },
            "processor_name": {
               "description": "The name of the processor that is importing the data.",
               "title": "Processor Name",
               "type": "string"
            },
            "processor_version": {
               "description": "The version of the processor that is importing the data.",
               "title": "Processor Version",
               "type": "string"
            },
            "notes": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "\nAny additional notes regarding the import (eg. reason for importing, known\nissues).\n        ",
               "title": "Notes"
            },
            "expected_reference_count": {
               "description": "\nThe number of references expected to be included in this import.\n-1 is accepted if the number is unknown.\n",
               "minimum": -1,
               "title": "Expected Reference Count",
               "type": "integer"
            },
            "source_name": {
               "description": "The source of the reference being imported (eg. Open Alex)",
               "title": "Source Name",
               "type": "string"
            },
            "status": {
               "$ref": "#/$defs/ImportRecordStatus",
               "default": "created",
               "description": "The status of the upload."
            },
            "batches": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/ImportBatch"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The batches associated with this import.",
               "title": "Batches"
            }
         },
         "required": [
            "processor_name",
            "processor_version",
            "expected_reference_count",
            "source_name"
         ],
         "title": "ImportRecord",
         "type": "object"
      },
      "ImportRecordStatus": {
         "description": "Describes the status of an import record.\n\n- `created`: Created, but no processing has started.\n- `started`: Processing has started on the batch.\n- `completed`: Processing has been completed.\n- `cancelled`: Processing was cancelled by calling the API.",
         "enum": [
            "created",
            "started",
            "completed",
            "cancelled"
         ],
         "title": "ImportRecordStatus",
         "type": "string"
      },
      "ImportResult": {
         "description": "Core import result model with database attributes included.",
         "properties": {
            "id": {
               "description": "The autogenerated database ID.",
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "import_batch_id": {
               "description": "The ID of the parent import batch.",
               "format": "uuid",
               "title": "Import Batch Id",
               "type": "string"
            },
            "status": {
               "$ref": "#/$defs/ImportResultStatus",
               "default": "created",
               "description": "The status of the result."
            },
            "import_batch": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/ImportBatch"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The parent import batch."
            },
            "reference_id": {
               "anyOf": [
                  {
                     "format": "uuid",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The ID of the created reference.",
               "title": "Reference Id"
            },
            "failure_details": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Details of any failure that occurred during processing.",
               "title": "Failure Details"
            }
         },
         "required": [
            "import_batch_id"
         ],
         "title": "ImportResult",
         "type": "object"
      },
      "ImportResultStatus": {
         "description": "Describes the status of an import result.\n\n- `created`: Created, but no processing has started.\n- `started`: The reference is currently being processed.\n- `completed`: The reference has been created.\n- `partially_failed`: The reference was created but one or more enhancements or\n  identifiers failed to be added. See the result's `failure_details` field for\n  more information.\n- `failed`: The reference failed to be created. See the result's `failure_details`\n  field for more information.\n- `cancelled`: Processing was cancelled by calling the API.",
         "enum": [
            "created",
            "started",
            "completed",
            "cancelled",
            "partially_failed",
            "failed"
         ],
         "title": "ImportResultStatus",
         "type": "string"
      }
   },
   "$ref": "#/$defs/ImportResult"
}

Config:
  • from_attributes: bool = True

Fields:
field failure_details: str | None = None[source]#

Details of any failure that occurred during processing.

field id: uuid.UUID [Optional][source]#

The autogenerated database ID.

field import_batch: ImportBatch | None = None[source]#

The parent import batch.

field import_batch_id: UUID [Required][source]#

The ID of the parent import batch.

field reference_id: UUID | None = None[source]#

The ID of the created reference.

field status: ImportResultStatus = ImportResultStatus.CREATED[source]#

The status of the result.

check_serializability() None[source]#

Check that incoming SDK model is json-serializable.

This should be called during all domain model conversions.

Raises:

ValidationError: If the model is not json-serializable.

async to_sdk() ImportResultRead[source]#

Convert the ImportResult to the SDK model.

class app.domain.imports.models.models.ImportResultStatus(*values)[source]#

Describes the status of an import result.

  • created: Created, but no processing has started.

  • started: The reference is currently being processed.

  • completed: The reference has been created.

  • partially_failed: The reference was created but one or more enhancements or identifiers failed to be added. See the result’s failure_details field for more information.

  • failed: The reference failed to be created. See the result’s failure_details field for more information.

  • cancelled: Processing was cancelled by calling the API.

CANCELLED = 'cancelled'[source]#
COMPLETED = 'completed'[source]#
CREATED = 'created'[source]#
FAILED = 'failed'[source]#
PARTIALLY_FAILED = 'partially_failed'[source]#
STARTED = 'started'[source]#