diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 866e93f..dd8fde7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.4.3" + ".": "1.5.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 37483a5..c827dcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [1.5.0](https://github.com/googleapis/python-optimization/compare/v1.4.3...v1.5.0) (2023-09-13) + + +### Features + +* Added support for walking mode and cost_per_kilometer_below_soft_max ([4095c0c](https://github.com/googleapis/python-optimization/commit/4095c0c17943f5fe833f411f11774305c5534377)) + + +### Documentation + +* Minor formatting ([a1952d2](https://github.com/googleapis/python-optimization/commit/a1952d2e272e774d3e1dfeef2c9b8ee8dc63a86d)) +* Minor formatting fix ([#148](https://github.com/googleapis/python-optimization/issues/148)) ([946f557](https://github.com/googleapis/python-optimization/commit/946f55708e81a45e7ed876fc22786c3490c60517)) + ## [1.4.3](https://github.com/googleapis/python-optimization/compare/v1.4.2...v1.4.3) (2023-08-16) diff --git a/docs/conf.py b/docs/conf.py index 3bb5e10..4ca0edb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,9 +24,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os import shlex +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/google/cloud/optimization/__init__.py b/google/cloud/optimization/__init__.py index dca538c..080d9b3 100644 --- a/google/cloud/optimization/__init__.py +++ b/google/cloud/optimization/__init__.py @@ -18,43 +18,44 @@ __version__ = package_version.__version__ +from google.cloud.optimization_v1.services.fleet_routing.async_client import ( + FleetRoutingAsyncClient, +) from google.cloud.optimization_v1.services.fleet_routing.client import ( FleetRoutingClient, ) -from google.cloud.optimization_v1.services.fleet_routing.async_client import ( - FleetRoutingAsyncClient, +from google.cloud.optimization_v1.types.async_model import ( + AsyncModelMetadata, + DataFormat, + GcsDestination, + GcsSource, + InputConfig, + OutputConfig, ) - -from google.cloud.optimization_v1.types.async_model import AsyncModelMetadata -from google.cloud.optimization_v1.types.async_model import GcsDestination -from google.cloud.optimization_v1.types.async_model import GcsSource -from google.cloud.optimization_v1.types.async_model import InputConfig -from google.cloud.optimization_v1.types.async_model import OutputConfig -from google.cloud.optimization_v1.types.async_model import DataFormat -from google.cloud.optimization_v1.types.fleet_routing import AggregatedMetrics -from google.cloud.optimization_v1.types.fleet_routing import BatchOptimizeToursRequest -from google.cloud.optimization_v1.types.fleet_routing import BatchOptimizeToursResponse -from google.cloud.optimization_v1.types.fleet_routing import BreakRule -from google.cloud.optimization_v1.types.fleet_routing import CapacityQuantity -from google.cloud.optimization_v1.types.fleet_routing import CapacityQuantityInterval -from google.cloud.optimization_v1.types.fleet_routing import DistanceLimit -from google.cloud.optimization_v1.types.fleet_routing import InjectedSolutionConstraint -from google.cloud.optimization_v1.types.fleet_routing import Location -from google.cloud.optimization_v1.types.fleet_routing import OptimizeToursRequest -from google.cloud.optimization_v1.types.fleet_routing import OptimizeToursResponse from google.cloud.optimization_v1.types.fleet_routing import ( + AggregatedMetrics, + BatchOptimizeToursRequest, + BatchOptimizeToursResponse, + BreakRule, + CapacityQuantity, + CapacityQuantityInterval, + DistanceLimit, + InjectedSolutionConstraint, + Location, + OptimizeToursRequest, + OptimizeToursResponse, OptimizeToursValidationError, + Shipment, + ShipmentModel, + ShipmentRoute, + ShipmentTypeIncompatibility, + ShipmentTypeRequirement, + SkippedShipment, + TimeWindow, + TransitionAttributes, + Vehicle, + Waypoint, ) -from google.cloud.optimization_v1.types.fleet_routing import Shipment -from google.cloud.optimization_v1.types.fleet_routing import ShipmentModel -from google.cloud.optimization_v1.types.fleet_routing import ShipmentRoute -from google.cloud.optimization_v1.types.fleet_routing import ShipmentTypeIncompatibility -from google.cloud.optimization_v1.types.fleet_routing import ShipmentTypeRequirement -from google.cloud.optimization_v1.types.fleet_routing import SkippedShipment -from google.cloud.optimization_v1.types.fleet_routing import TimeWindow -from google.cloud.optimization_v1.types.fleet_routing import TransitionAttributes -from google.cloud.optimization_v1.types.fleet_routing import Vehicle -from google.cloud.optimization_v1.types.fleet_routing import Waypoint __all__ = ( "FleetRoutingClient", diff --git a/google/cloud/optimization/gapic_version.py b/google/cloud/optimization/gapic_version.py index 178df4b..997edc1 100644 --- a/google/cloud/optimization/gapic_version.py +++ b/google/cloud/optimization/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.4.3" # {x-release-please-version} +__version__ = "1.5.0" # {x-release-please-version} diff --git a/google/cloud/optimization_v1/__init__.py b/google/cloud/optimization_v1/__init__.py index 599bee8..ef40fdb 100644 --- a/google/cloud/optimization_v1/__init__.py +++ b/google/cloud/optimization_v1/__init__.py @@ -18,37 +18,39 @@ __version__ = package_version.__version__ -from .services.fleet_routing import FleetRoutingClient -from .services.fleet_routing import FleetRoutingAsyncClient - -from .types.async_model import AsyncModelMetadata -from .types.async_model import GcsDestination -from .types.async_model import GcsSource -from .types.async_model import InputConfig -from .types.async_model import OutputConfig -from .types.async_model import DataFormat -from .types.fleet_routing import AggregatedMetrics -from .types.fleet_routing import BatchOptimizeToursRequest -from .types.fleet_routing import BatchOptimizeToursResponse -from .types.fleet_routing import BreakRule -from .types.fleet_routing import CapacityQuantity -from .types.fleet_routing import CapacityQuantityInterval -from .types.fleet_routing import DistanceLimit -from .types.fleet_routing import InjectedSolutionConstraint -from .types.fleet_routing import Location -from .types.fleet_routing import OptimizeToursRequest -from .types.fleet_routing import OptimizeToursResponse -from .types.fleet_routing import OptimizeToursValidationError -from .types.fleet_routing import Shipment -from .types.fleet_routing import ShipmentModel -from .types.fleet_routing import ShipmentRoute -from .types.fleet_routing import ShipmentTypeIncompatibility -from .types.fleet_routing import ShipmentTypeRequirement -from .types.fleet_routing import SkippedShipment -from .types.fleet_routing import TimeWindow -from .types.fleet_routing import TransitionAttributes -from .types.fleet_routing import Vehicle -from .types.fleet_routing import Waypoint +from .services.fleet_routing import FleetRoutingAsyncClient, FleetRoutingClient +from .types.async_model import ( + AsyncModelMetadata, + DataFormat, + GcsDestination, + GcsSource, + InputConfig, + OutputConfig, +) +from .types.fleet_routing import ( + AggregatedMetrics, + BatchOptimizeToursRequest, + BatchOptimizeToursResponse, + BreakRule, + CapacityQuantity, + CapacityQuantityInterval, + DistanceLimit, + InjectedSolutionConstraint, + Location, + OptimizeToursRequest, + OptimizeToursResponse, + OptimizeToursValidationError, + Shipment, + ShipmentModel, + ShipmentRoute, + ShipmentTypeIncompatibility, + ShipmentTypeRequirement, + SkippedShipment, + TimeWindow, + TransitionAttributes, + Vehicle, + Waypoint, +) __all__ = ( "FleetRoutingAsyncClient", diff --git a/google/cloud/optimization_v1/gapic_version.py b/google/cloud/optimization_v1/gapic_version.py index 178df4b..997edc1 100644 --- a/google/cloud/optimization_v1/gapic_version.py +++ b/google/cloud/optimization_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.4.3" # {x-release-please-version} +__version__ = "1.5.0" # {x-release-please-version} diff --git a/google/cloud/optimization_v1/services/fleet_routing/__init__.py b/google/cloud/optimization_v1/services/fleet_routing/__init__.py index 046ba5f..c619cbe 100644 --- a/google/cloud/optimization_v1/services/fleet_routing/__init__.py +++ b/google/cloud/optimization_v1/services/fleet_routing/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import FleetRoutingClient from .async_client import FleetRoutingAsyncClient +from .client import FleetRoutingClient __all__ = ( "FleetRoutingClient", diff --git a/google/cloud/optimization_v1/services/fleet_routing/async_client.py b/google/cloud/optimization_v1/services/fleet_routing/async_client.py index 5d7eb37..d2a47ed 100644 --- a/google/cloud/optimization_v1/services/fleet_routing/async_client.py +++ b/google/cloud/optimization_v1/services/fleet_routing/async_client.py @@ -28,15 +28,15 @@ Union, ) -from google.cloud.optimization_v1 import gapic_version as package_version - -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +from google.cloud.optimization_v1 import gapic_version as package_version + try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER @@ -44,12 +44,13 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.optimization_v1.types import async_model -from google.cloud.optimization_v1.types import fleet_routing -from google.longrunning import operations_pb2 -from .transports.base import FleetRoutingTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import FleetRoutingGrpcAsyncIOTransport +from google.longrunning import operations_pb2 # type: ignore + +from google.cloud.optimization_v1.types import async_model, fleet_routing + from .client import FleetRoutingClient +from .transports.base import DEFAULT_CLIENT_INFO, FleetRoutingTransport +from .transports.grpc_asyncio import FleetRoutingGrpcAsyncIOTransport class FleetRoutingAsyncClient: diff --git a/google/cloud/optimization_v1/services/fleet_routing/client.py b/google/cloud/optimization_v1/services/fleet_routing/client.py index 176062e..e4ea332 100644 --- a/google/cloud/optimization_v1/services/fleet_routing/client.py +++ b/google/cloud/optimization_v1/services/fleet_routing/client.py @@ -29,18 +29,18 @@ cast, ) -from google.cloud.optimization_v1 import gapic_version as package_version - from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +from google.cloud.optimization_v1 import gapic_version as package_version + try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER @@ -48,10 +48,11 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.optimization_v1.types import async_model -from google.cloud.optimization_v1.types import fleet_routing -from google.longrunning import operations_pb2 -from .transports.base import FleetRoutingTransport, DEFAULT_CLIENT_INFO +from google.longrunning import operations_pb2 # type: ignore + +from google.cloud.optimization_v1.types import async_model, fleet_routing + +from .transports.base import DEFAULT_CLIENT_INFO, FleetRoutingTransport from .transports.grpc import FleetRoutingGrpcTransport from .transports.grpc_asyncio import FleetRoutingGrpcAsyncIOTransport from .transports.rest import FleetRoutingRestTransport diff --git a/google/cloud/optimization_v1/services/fleet_routing/transports/__init__.py b/google/cloud/optimization_v1/services/fleet_routing/transports/__init__.py index 05c06da..b5dc57f 100644 --- a/google/cloud/optimization_v1/services/fleet_routing/transports/__init__.py +++ b/google/cloud/optimization_v1/services/fleet_routing/transports/__init__.py @@ -19,9 +19,7 @@ from .base import FleetRoutingTransport from .grpc import FleetRoutingGrpcTransport from .grpc_asyncio import FleetRoutingGrpcAsyncIOTransport -from .rest import FleetRoutingRestTransport -from .rest import FleetRoutingRestInterceptor - +from .rest import FleetRoutingRestInterceptor, FleetRoutingRestTransport # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[FleetRoutingTransport]] diff --git a/google/cloud/optimization_v1/services/fleet_routing/transports/base.py b/google/cloud/optimization_v1/services/fleet_routing/transports/base.py index 7d9bd83..c52f75e 100644 --- a/google/cloud/optimization_v1/services/fleet_routing/transports/base.py +++ b/google/cloud/optimization_v1/services/fleet_routing/transports/base.py @@ -16,20 +16,17 @@ import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -from google.cloud.optimization_v1 import gapic_version as package_version - -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, operations_v1 from google.api_core import retry as retries -from google.api_core import operations_v1 +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore +from google.cloud.optimization_v1 import gapic_version as package_version from google.cloud.optimization_v1.types import fleet_routing -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=package_version.__version__ diff --git a/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py b/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py index fd38ad7..1628583 100644 --- a/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py +++ b/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py @@ -13,22 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers, operations_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.optimization_v1.types import fleet_routing -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from .base import FleetRoutingTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, FleetRoutingTransport class FleetRoutingGrpcTransport(FleetRoutingTransport): diff --git a/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py b/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py index cf3f16f..94a487f 100644 --- a/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py +++ b/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py @@ -13,22 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 +from google.api_core import gapic_v1, grpc_helpers_async, operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.optimization_v1.types import fleet_routing -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from .base import FleetRoutingTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, FleetRoutingTransport from .grpc import FleetRoutingGrpcTransport diff --git a/google/cloud/optimization_v1/services/fleet_routing/transports/rest.py b/google/cloud/optimization_v1/services/fleet_routing/transports/rest.py index 85feaf4..c21c0fa 100644 --- a/google/cloud/optimization_v1/services/fleet_routing/transports/rest.py +++ b/google/cloud/optimization_v1/services/fleet_routing/transports/rest.py @@ -14,26 +14,27 @@ # limitations under the License. # -from google.auth.transport.requests import AuthorizedSession # type: ignore +import dataclasses import json # type: ignore -import grpc # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth import credentials as ga_credentials # type: ignore +import re +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union +import warnings + +from google.api_core import ( + gapic_v1, + operations_v1, + path_template, + rest_helpers, + rest_streaming, +) from google.api_core import exceptions as core_exceptions from google.api_core import retry as retries -from google.api_core import rest_helpers -from google.api_core import rest_streaming -from google.api_core import path_template -from google.api_core import gapic_v1 - +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.transport.requests import AuthorizedSession # type: ignore from google.protobuf import json_format -from google.api_core import operations_v1 -from google.longrunning import operations_pb2 +import grpc # type: ignore from requests import __version__ as requests_version -import dataclasses -import re -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -import warnings try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -41,11 +42,12 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore -from google.cloud.optimization_v1.types import fleet_routing from google.longrunning import operations_pb2 # type: ignore -from .base import FleetRoutingTransport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO +from google.cloud.optimization_v1.types import fleet_routing +from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO +from .base import FleetRoutingTransport DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, diff --git a/google/cloud/optimization_v1/types/__init__.py b/google/cloud/optimization_v1/types/__init__.py index 197d7cb..e66aaf5 100644 --- a/google/cloud/optimization_v1/types/__init__.py +++ b/google/cloud/optimization_v1/types/__init__.py @@ -15,11 +15,11 @@ # from .async_model import ( AsyncModelMetadata, + DataFormat, GcsDestination, GcsSource, InputConfig, OutputConfig, - DataFormat, ) from .fleet_routing import ( AggregatedMetrics, diff --git a/google/cloud/optimization_v1/types/async_model.py b/google/cloud/optimization_v1/types/async_model.py index 744c164..448400a 100644 --- a/google/cloud/optimization_v1/types/async_model.py +++ b/google/cloud/optimization_v1/types/async_model.py @@ -17,10 +17,8 @@ from typing import MutableMapping, MutableSequence -import proto # type: ignore - from google.protobuf import timestamp_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( package="google.cloud.optimization.v1", diff --git a/google/cloud/optimization_v1/types/fleet_routing.py b/google/cloud/optimization_v1/types/fleet_routing.py index 827b89e..fad2b3a 100644 --- a/google/cloud/optimization_v1/types/fleet_routing.py +++ b/google/cloud/optimization_v1/types/fleet_routing.py @@ -17,13 +17,12 @@ from typing import MutableMapping, MutableSequence -import proto # type: ignore - -from google.cloud.optimization_v1.types import async_model from google.protobuf import duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.type import latlng_pb2 # type: ignore +import proto # type: ignore +from google.cloud.optimization_v1.types import async_model __protobuf__ = proto.module( package="google.cloud.optimization.v1", @@ -83,16 +82,6 @@ class OptimizeToursRequest(proto.Message): Shipment model to solve. solving_mode (google.cloud.optimization_v1.types.OptimizeToursRequest.SolvingMode): By default, the solving mode is ``DEFAULT_SOLVE`` (0). - max_validation_errors (int): - Truncates the number of validation errors returned. These - errors are typically attached to an INVALID_ARGUMENT error - payload as a BadRequest error detail - (https://cloud.google.com/apis/design/errors#error_details), - unless solving_mode=VALIDATE_ONLY: see the - [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors] - field. This defaults to 100 and is capped at 10,000. - - This field is a member of `oneof`_ ``_max_validation_errors``. search_mode (google.cloud.optimization_v1.types.OptimizeToursRequest.SearchMode): Search mode used to solve the request. injected_first_solution_routes (MutableSequence[google.cloud.optimization_v1.types.ShipmentRoute]): @@ -271,6 +260,16 @@ class OptimizeToursRequest(proto.Message): Its value must be at least 1.0 meters/seconds. This field is a member of `oneof`_ ``_geodesic_meters_per_second``. + max_validation_errors (int): + Truncates the number of validation errors returned. These + errors are typically attached to an INVALID_ARGUMENT error + payload as a BadRequest error detail + (https://cloud.google.com/apis/design/errors#error_details), + unless solving_mode=VALIDATE_ONLY: see the + [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors] + field. This defaults to 100 and is capped at 10,000. + + This field is a member of `oneof`_ ``_max_validation_errors``. label (str): Label that may be used to identify this request, reported back in the @@ -301,12 +300,20 @@ class SolvingMode(proto.Enum): as possible. DETECT_SOME_INFEASIBLE_SHIPMENTS (2): Only populates + [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors] + or [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments], and doesn't actually solve the rest of the request - (``status`` and ``routes`` are unset in the response). + (``status`` and ``routes`` are unset in the response). If + infeasibilities in ``injected_solution_constraint`` routes + are detected they are populated in the + [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors] + field and + [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments] + is left empty. *IMPORTANT*: not all infeasible shipments are returned here, - but only the ones that are detected as infeasible as a + but only the ones that are detected as infeasible during preprocessing. """ DEFAULT_SOLVE = 0 @@ -351,11 +358,6 @@ class SearchMode(proto.Enum): number=4, enum=SolvingMode, ) - max_validation_errors: int = proto.Field( - proto.INT32, - number=5, - optional=True, - ) search_mode: SearchMode = proto.Field( proto.ENUM, number=6, @@ -407,6 +409,11 @@ class SearchMode(proto.Enum): number=16, optional=True, ) + max_validation_errors: int = proto.Field( + proto.INT32, + number=5, + optional=True, + ) label: str = proto.Field( proto.STRING, number=17, @@ -686,8 +693,7 @@ class ShipmentModel(proto.Message): 1970 (i.e. seconds: 0, nanos: 0) is used as default. global_end_time (google.protobuf.timestamp_pb2.Timestamp): If unset, 00:00:00 UTC, January 1, 1971 (i.e. - seconds: 31536000, nanos: 0) - is used as default. + seconds: 31536000, nanos: 0) is used as default. global_duration_cost_per_hour (float): The "global duration" of the overall plan is the difference between the earliest effective start time and the latest @@ -1331,10 +1337,10 @@ class Shipment(proto.Message): class VisitRequest(proto.Message): r"""Request for a visit which can be done by a vehicle: it has a - geo-location - (or two, see below), opening and closing times represented by - time windows, and a service duration time (time spent by the - vehicle once it has arrived to pickup or drop off goods). + geo-location (or two, see below), opening and closing times + represented by time windows, and a service duration time (time + spent by the vehicle once it has arrived to pickup or drop off + goods). Attributes: arrival_location (google.type.latlng_pb2.LatLng): @@ -1915,9 +1921,13 @@ class TravelMode(proto.Enum): DRIVING (1): Travel mode corresponding to driving directions (car, ...). + WALKING (2): + Travel mode corresponding to walking + directions. """ TRAVEL_MODE_UNSPECIFIED = 0 DRIVING = 1 + WALKING = 2 class UnloadingPolicy(proto.Enum): r"""Policy on how a vehicle can be unloaded. Applies only to shipments @@ -2450,6 +2460,18 @@ class DistanceLimit(proto.Message): must be nonnegative. This field is a member of `oneof`_ ``_soft_max_meters``. + cost_per_kilometer_below_soft_max (float): + Cost per kilometer incurred, increasing up to + ``soft_max_meters``, with formula: + + :: + + min(distance_meters, soft_max_meters) / 1000.0 * + cost_per_kilometer_below_soft_max. + + This cost is not supported in ``route_distance_limit``. + + This field is a member of `oneof`_ ``_cost_per_kilometer_below_soft_max``. cost_per_kilometer_above_soft_max (float): Cost per kilometer incurred if distance is above ``soft_max_meters`` limit. The additional cost is 0 if the @@ -2476,6 +2498,11 @@ class DistanceLimit(proto.Message): number=2, optional=True, ) + cost_per_kilometer_below_soft_max: float = proto.Field( + proto.DOUBLE, + number=4, + optional=True, + ) cost_per_kilometer_above_soft_max: float = proto.Field( proto.DOUBLE, number=3, @@ -3647,12 +3674,9 @@ class AggregatedMetrics(proto.Message): total_duration (google.protobuf.duration_pb2.Duration): The total duration should be equal to the sum of all durations above. For routes, it also corresponds to: - - :: - - [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time] - - - [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time] + [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time] + ``-`` + [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time] travel_distance_meters (float): Total travel distance for a route or a solution. @@ -3861,8 +3885,8 @@ class Level(proto.Enum): or before them. RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD (2): Same as ``RELAX_VISIT_TIMES_AFTER_THRESHOLD``, but the visit - sequence is also relaxed: visits remain simply bound to - their vehicle. + sequence is also relaxed: visits can only be performed by + this vehicle, but can potentially become unperformed. RELAX_ALL_AFTER_THRESHOLD (3): Same as ``RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD``, but the vehicle is also relaxed: visits are completely free @@ -3988,6 +4012,8 @@ class OptimizeToursValidationError(proto.Message): - INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005; - INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006; - INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008; + - INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE + = 2010; - SHIPMENT_MODEL_ERROR = 22; diff --git a/noxfile.py b/noxfile.py index 2b3b1bf..4000733 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,6 +17,7 @@ # Generated by synthtool. DO NOT EDIT! from __future__ import absolute_import + import os import pathlib import re diff --git a/owlbot.py b/owlbot.py index 72f2337..ce738f0 100644 --- a/owlbot.py +++ b/owlbot.py @@ -35,10 +35,6 @@ if clean_up_generated_samples: shutil.rmtree("samples/generated_samples", ignore_errors=True) clean_up_generated_samples = False - s.replace(library / "google/cloud/optimization_v1/types/fleet_routing.py", - "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n", - "" - ) s.move([library], excludes=["**/gapic_version.py"]) s.remove_staging_dirs() @@ -57,4 +53,4 @@ # run format session for all directories which have a noxfile for noxfile in Path(".").glob("**/noxfile.py"): - s.shell.run(["nox", "-s", "blacken"], cwd=noxfile.parent, hide_output=False) + s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False) diff --git a/samples/generated_samples/snippet_metadata_google.cloud.optimization.v1.json b/samples/generated_samples/snippet_metadata_google.cloud.optimization.v1.json index 5d40c39..13b5f0d 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.optimization.v1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.optimization.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-optimization", - "version": "1.4.3" + "version": "1.5.0" }, "snippets": [ { diff --git a/scripts/fixup_optimization_v1_keywords.py b/scripts/fixup_optimization_v1_keywords.py index 25146b7..6d3a6f4 100644 --- a/scripts/fixup_optimization_v1_keywords.py +++ b/scripts/fixup_optimization_v1_keywords.py @@ -40,7 +40,7 @@ class optimizationCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'batch_optimize_tours': ('parent', 'model_configs', ), - 'optimize_tours': ('parent', 'timeout', 'model', 'solving_mode', 'max_validation_errors', 'search_mode', 'injected_first_solution_routes', 'injected_solution_constraint', 'refresh_details_routes', 'interpret_injected_solutions_using_labels', 'consider_road_traffic', 'populate_polylines', 'populate_transition_polylines', 'allow_large_deadline_despite_interruption_risk', 'use_geodesic_distances', 'geodesic_meters_per_second', 'label', 'populate_travel_step_polylines', ), + 'optimize_tours': ('parent', 'timeout', 'model', 'solving_mode', 'search_mode', 'injected_first_solution_routes', 'injected_solution_constraint', 'refresh_details_routes', 'interpret_injected_solutions_using_labels', 'consider_road_traffic', 'populate_polylines', 'populate_transition_polylines', 'allow_large_deadline_despite_interruption_risk', 'use_geodesic_distances', 'geodesic_meters_per_second', 'max_validation_errors', 'label', 'populate_travel_step_polylines', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: diff --git a/tests/unit/gapic/optimization_v1/test_fleet_routing.py b/tests/unit/gapic/optimization_v1/test_fleet_routing.py index b7bb6ed..09838a2 100644 --- a/tests/unit/gapic/optimization_v1/test_fleet_routing.py +++ b/tests/unit/gapic/optimization_v1/test_fleet_routing.py @@ -22,43 +22,45 @@ except ImportError: # pragma: NO COVER import mock -import grpc -from grpc.experimental import aio from collections.abc import Iterable -from google.protobuf import json_format import json import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule -from proto.marshal.rules import wrappers -from requests import Response -from requests import Request, PreparedRequest -from requests.sessions import Session -from google.protobuf import json_format +from google.api_core import ( + future, + gapic_v1, + grpc_helpers, + grpc_helpers_async, + operation, + operations_v1, + path_template, +) from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.optimization_v1.services.fleet_routing import FleetRoutingAsyncClient -from google.cloud.optimization_v1.services.fleet_routing import FleetRoutingClient -from google.cloud.optimization_v1.services.fleet_routing import transports -from google.cloud.optimization_v1.types import async_model -from google.cloud.optimization_v1.types import fleet_routing -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import json_format from google.protobuf import timestamp_pb2 # type: ignore from google.type import latlng_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +from proto.marshal.rules import wrappers +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest +from requests import PreparedRequest, Request, Response +from requests.sessions import Session + +from google.cloud.optimization_v1.services.fleet_routing import ( + FleetRoutingAsyncClient, + FleetRoutingClient, + transports, +) +from google.cloud.optimization_v1.types import async_model, fleet_routing def client_cert_source_callback():