-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat: Create sample for routeoptimization #12118
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
base: main
Are you sure you want to change the base?
Conversation
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
Tests blocked by API enablement (or enablement propagation) |
Enabled the api in the testing project, re-running tests. |
Looks like that field doesn't exist? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi team,
I'm currently reviewing this pull request and will provide feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:
This pull request, authored by bshi, aims to add a new sample for the Route Optimization API. The changes include:
- Added a new sample directory:
routeoptimization/snippets/
containing code for optimizing tours using the Route Optimization API. - Updated
CODEOWNERS
: Line 120 was added to assign ownership of the new sample directory to@GoogleCloudPlatform/geo-routeoptimization
,@GoogleCloudPlatform/python-samples-reviewers
, and@GoogleCloudPlatform/cloud-samples-reviewers
. - Updated
blunderbuss.yml
: Lines 330-332 were added to automatically assign reviewers for pull requests related to the Route Optimization API to@GoogleCloudPlatform/geo-routeoptimization
. - Added a
README.rst
file: This file provides instructions on setting up the environment and running the sample code (lines 1-20). - Added
noxfile_config.py
: This file configures the testing environment (lines 1-42). - Added
optimize_tours.py
: This file contains the core logic for optimizing tours (lines 1-59). - Added
optimize_tours_test.py
: This file contains unit tests for the sample code (lines 1-28). - Added
requirements-test.txt
: Specifies testing dependencies (lines 1-2). - Added
requirements.txt
: Specifies runtime dependencies (line 1).
The author has indicated that the Route Optimization API needs to be enabled in testing projects, and the pull request includes a checklist to ensure all necessary steps are completed before merging. I'll be checking the test results and code quality during my review.
Here's a little haiku to brighten your day:
Routes optimize now,
Code flows smoothly, clear and bright,
Happy testing all!
@davidcavazos I apologize for the delay. Addressed your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request adds a sample for the Route Optimization API. The sample code looks good, and the tests seem well-structured. However, there are a few minor improvements and a couple of missing checks that need to be addressed before merging.
195c19e
to
e3ada70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi team,
I'm currently reviewing this pull request and will provide my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed:
This pull request, authored by bshi, aims to add a new sample for the Route Optimization API. The changes include:
- New sample directory: A new directory
routeoptimization/snippets
has been created to house the sample code. - Updated
CODEOWNERS
file (line 92): TheCODEOWNERS
file has been updated to assign ownership of the new sample directory to the@GoogleCloudPlatform/geo-routeoptimization
,@GoogleCloudPlatform/python-samples-reviewers
, and@GoogleCloudPlatform/cloud-samples-reviewers
teams. - Updated
blunderbuss.yml
file (lines 261-265): Theblunderbuss.yml
file has been updated to correctly assign pull requests related to the Route Optimization API to the appropriate team. - New README.rst file (routeoptimization/snippets/README.rst): A new README file provides instructions for setting up and running the sample locally. (lines 1-20)
- New Python sample file (routeoptimization/snippets/optimize_tours.py): This file contains the core logic for using the Route Optimization API. (lines 1-59)
- New test file (routeoptimization/snippets/optimize_tours_test.py): This file includes tests to verify the functionality of the sample code. (lines 1-29)
- New requirements files:
requirements.txt
andrequirements-test.txt
specify the necessary dependencies for the sample and its tests. (lines 1-2 and 1-1 respectively) - New noxfile_config.py: This file contains configuration for the nox testing framework. (lines 1-42)
The author has indicated that the Route Optimization API needs to be enabled in testing projects, and that tests pass using nox -s py-3.9
and nox -s lint
.
I'll be checking the functionality and code quality shortly. Let me know if you have any questions in the meantime.
And now, a little haiku to brighten your day:
Routes optimize well,
Code flows smoothly, clear and bright,
Review's a swift breeze.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sample code and tests look good. A few minor suggestions for improvement are included below.
from google.maps import routeoptimization_v1 | ||
|
||
|
||
def call_optimize_tours(project_id: str) -> routeoptimization_v1.OptimizeToursResponse: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good practice to include a docstring briefly explaining what the function does.
def call_optimize_tours(project_id: str) -> routeoptimization_v1.OptimizeToursResponse: | |
def call_optimize_tours(project_id: str) -> routeoptimization_v1.OptimizeToursResponse: | |
"""Calls the optimize tours method.""" |
|
||
response = client.optimize_tours( | ||
request=routeoptimization_v1.OptimizeToursRequest( | ||
parent="projects/" + project_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import optimize_tours | ||
|
||
|
||
@Retry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
def call_optimize_tours(project_id: str) -> routeoptimization_v1.OptimizeToursResponse: | ||
# Use Default Application Credentials for the environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good practice to explicitly set the retry
argument. Refer to this documentation for more details: https://googleapis.dev/python/google-api-core/latest/retry.html
# Use Default Application Credentials for the environment. | |
client = routeoptimization_v1.RouteOptimizationClient(client_options={'api_endpoint': 'us-central1-routeoptimization.googleapis.com:443'}) |
|
||
|
||
@Retry | ||
def test_call_sync_api() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good practice to explicitly set the retry
argument. Refer to this documentation for more details: https://googleapis.dev/python/google-api-core/latest/retry.html
def test_call_sync_api() -> None: | |
@Retry(deadline=600) | |
def test_call_sync_api() -> None: |
Since this PR was created, we're introduced Python 3.13 testing. Please rebase this PR to ensure this check passes (if this API doesn't yet support Python 3.13, please update the noxfile to ignore this version) |
Description
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
nox -s py-3.9
(see Test Environment Setup)nox -s lint
(see Test Environment Setup)