Implantar uma versão do processador
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Depois de criar uma nova versão do processador, você precisa implantá-la antes de processar documentos com ela.
Observação: não é possível mudar o status de implantação das versões de processador pré-treinadas ou da versão padrão atual.
Mais informações
Para ver a documentação detalhada que inclui este exemplo de código, consulte:
Exemplo de código
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],[],[[["\u003cp\u003eNew processor versions must be deployed before they can be used to process documents.\u003c/p\u003e\n"],["\u003cp\u003eThe deployment status of pretrained processor versions or the default version cannot be changed.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code sample demonstrates how to deploy a processor version using the Document AI Python API.\u003c/p\u003e\n"],["\u003cp\u003eTo access detailed documentation and API references, refer to the provided links for managing processor versions and the Document AI Python API reference.\u003c/p\u003e\n"],["\u003cp\u003eApplication Default Credentials must be setup for successful authentication to Document AI, as detailed in the provided link.\u003c/p\u003e\n"]]],[],null,["After creating a new processor version, you will need to deploy it before you can process documents with this version.\n\nNote: You cannot change the deployment status for pretrained processor versions or the current default version.\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Managing processor versions](/document-ai/docs/manage-processor-versions)\n\nCode sample \n\nPython\n\n\nFor more information, see the\n[Document AI Python API\nreference documentation](/python/docs/reference/documentai/latest).\n\n\nTo authenticate to Document AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n from google.api_core.client_options import ClientOptions\n from google.api_core.exceptions import FailedPrecondition\n from google.cloud import documentai # type: ignore\n\n # TODO(developer): Uncomment these variables before running the sample.\n # project_id = 'YOUR_PROJECT_ID'\n # location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'\n # processor_id = 'YOUR_PROCESSOR_ID'\n # processor_version_id = 'YOUR_PROCESSOR_VERSION_ID'\n\n\n def deploy_processor_version_sample(\n project_id: str, location: str, processor_id: str, processor_version_id: str\n ) -\u003e None:\n # You must set the api_endpoint if you use a location other than 'us'.\n opts = ClientOptions(api_endpoint=f\"{location}-documentai.googleapis.com\")\n\n client = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html(client_options=opts)\n\n # The full resource name of the processor version\n # e.g.: projects/project_id/locations/location/processors/processor_id/processorVersions/processor_version_id\n name = client.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html#google_cloud_documentai_v1_services_document_processor_service_DocumentProcessorServiceClient_processor_version_path(\n project_id, location, processor_id, processor_version_id\n )\n\n # Make DeployProcessorVersion request\n try:\n operation = client.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html#google_cloud_documentai_v1_services_document_processor_service_DocumentProcessorServiceClient_deploy_processor_version(name=name)\n # Print operation details\n print(operation.operation.name)\n # Wait for operation to complete\n operation.result()\n # Deploy request will fail if the\n # processor version is already deployed\n except FailedPrecondition as e:\n print(e.message)\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=documentai)."]]