Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: exposed Import PV external_processor_version_source to v1beta3 public #11517

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/google-cloud-documentai/.flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-documentai/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ We support:

Supported versions can be found in our ``noxfile.py`` `config`_.

.. _config: https://github.com/googleapis/google-cloud-python/blob/main/noxfile.py
.. _config: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-documentai/noxfile.py


**********
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-documentai/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
27 changes: 14 additions & 13 deletions packages/google-cloud-documentai/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,24 @@ In order to use this library, you first need to go through the following steps:
Installation
~~~~~~~~~~~~

Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
create isolated Python environments. The basic problem it addresses is one of
dependencies and versions, and indirectly permissions.
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
creates isolated Python environments. These isolated environments can have separate
versions of Python packages, which allows you to isolate one project's dependencies
from the dependencies of other projects.

With `virtualenv`_, it's possible to install this library without needing system
With `venv`_, it's possible to install this library without needing system
install permissions, and without clashing with the installed system
dependencies.

.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
.. _`venv`: https://docs.python.org/3/library/venv.html


Code samples and snippets
~~~~~~~~~~~~~~~~~~~~~~~~~

Code samples and snippets live in the `samples/` folder.
Code samples and snippets live in the `samples/`_ folder.

.. _samples/: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-documentai/samples


Supported Python Versions
Expand All @@ -77,21 +80,19 @@ Mac/Linux

.. code-block:: console

pip install virtualenv
virtualenv <your-env>
python3 -m venv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-documentai
pip install google-cloud-documentai


Windows
^^^^^^^

.. code-block:: console

pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-documentai
py -m venv <your-env>
.\<your-env>\Scripts\activate
pip install google-cloud-documentai

Next Steps
~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-documentai/docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2021 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.17.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.17.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.17.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.17.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -2920,8 +2920,6 @@ async def sample_import_processor_version():
[ImportProcessorVersion][google.cloud.documentai.v1beta3.DocumentProcessorService.ImportProcessorVersion]
method. Requirements:

- The source processor version and destination
processor must be in the same location.
- The Document AI `Service
Agent <https://cloud.google.com/iam/docs/service-agents>`__
of the destination project must have `Document AI
Expand All @@ -2932,7 +2930,9 @@ async def sample_import_processor_version():
The destination project is specified as part of the
[parent][google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.parent]
field. The source project is specified as part of the
[source][google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.processor_version_source]
[source][ImportProcessorVersionRequest.processor_version_source
or
ImportProcessorVersionRequest.external_processor_version_source]
field.
parent (:class:`str`):
Required. The destination processor name to create the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3219,8 +3219,6 @@ def sample_import_processor_version():
[ImportProcessorVersion][google.cloud.documentai.v1beta3.DocumentProcessorService.ImportProcessorVersion]
method. Requirements:

- The source processor version and destination
processor must be in the same location.
- The Document AI `Service
Agent <https://cloud.google.com/iam/docs/service-agents>`__
of the destination project must have `Document AI
Expand All @@ -3231,7 +3229,9 @@ def sample_import_processor_version():
The destination project is specified as part of the
[parent][google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.parent]
field. The source project is specified as part of the
[source][google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.processor_version_source]
[source][ImportProcessorVersionRequest.processor_version_source
or
ImportProcessorVersionRequest.external_processor_version_source]
field.
parent (str):
Required. The destination processor name to create the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2417,8 +2417,6 @@ def __call__(
[ImportProcessorVersion][google.cloud.documentai.v1beta3.DocumentProcessorService.ImportProcessorVersion]
method. Requirements:

- The source processor version and destination
processor must be in the same location.
- The Document AI `Service
Agent <https://cloud.google.com/iam/docs/service-agents>`__
of the destination project must have `Document AI
Expand All @@ -2429,7 +2427,9 @@ def __call__(
The destination project is specified as part of the
[parent][google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.parent]
field. The source project is specified as part of the
[source][google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.processor_version_source]
[source][ImportProcessorVersionRequest.processor_version_source
or
ImportProcessorVersionRequest.external_processor_version_source]
field.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1698,8 +1698,6 @@ class ImportProcessorVersionRequest(proto.Message):
[ImportProcessorVersion][google.cloud.documentai.v1beta3.DocumentProcessorService.ImportProcessorVersion]
method. Requirements:

- The source processor version and destination processor must be in
the same location.
- The Document AI `Service
Agent <https://cloud.google.com/iam/docs/service-agents>`__ of
the destination project must have `Document AI Editor
Expand All @@ -1709,9 +1707,14 @@ class ImportProcessorVersionRequest(proto.Message):
The destination project is specified as part of the
[parent][google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.parent]
field. The source project is specified as part of the
[source][google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.processor_version_source]
[source][ImportProcessorVersionRequest.processor_version_source or
ImportProcessorVersionRequest.external_processor_version_source]
field.

This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Expand All @@ -1722,18 +1725,52 @@ class ImportProcessorVersionRequest(proto.Message):
processor need to be in the same environment and
region.

This field is a member of `oneof`_ ``source``.
external_processor_version_source (google.cloud.documentai_v1beta3.types.ImportProcessorVersionRequest.ExternalProcessorVersionSource):
The source processor version to import from,
and can be from different environment and region
than the destination processor.

This field is a member of `oneof`_ ``source``.
parent (str):
Required. The destination processor name to create the
processor version in. Format:
``projects/{project}/locations/{location}/processors/{processor}``
"""

class ExternalProcessorVersionSource(proto.Message):
r"""The external source processor version.

Attributes:
processor_version (str):
Required. The processor version name. Format:
``projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}``
service_endpoint (str):
Optional. The Document AI service endpoint.
For example,
'https://us-documentai.googleapis.com'
"""

processor_version: str = proto.Field(
proto.STRING,
number=1,
)
service_endpoint: str = proto.Field(
proto.STRING,
number=2,
)

processor_version_source: str = proto.Field(
proto.STRING,
number=2,
oneof="source",
)
external_processor_version_source: ExternalProcessorVersionSource = proto.Field(
proto.MESSAGE,
number=3,
oneof="source",
message=ExternalProcessorVersionSource,
)
parent: str = proto.Field(
proto.STRING,
number=1,
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-documentai/noxfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2018 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-documentai",
"version": "2.17.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-documentai",
"version": "2.17.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-documentai",
"version": "2.17.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2015 Google Inc. All rights reserved.
# Copyright 2023 Google LLC All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class documentaiCallTransformer(cst.CSTTransformer):
'get_processor_type': ('name', ),
'get_processor_version': ('name', ),
'import_documents': ('dataset', 'batch_documents_import_configs', ),
'import_processor_version': ('parent', 'processor_version_source', ),
'import_processor_version': ('parent', 'processor_version_source', 'external_processor_version_source', ),
'list_evaluations': ('parent', 'page_size', 'page_token', ),
'list_processors': ('parent', 'page_size', 'page_token', ),
'list_processor_types': ('parent', 'page_size', 'page_token', ),
Expand Down