[
https://issues.apache.org/jira/browse/BEAM-8472?focusedWorklogId=333631&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-333631
]
ASF GitHub Bot logged work on BEAM-8472:
----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Oct/19 18:14
Start Date: 24/Oct/19 18:14
Worklog Time Spent: 10m
Work Description: aaltay commented on pull request #9868: [BEAM-8472] get
default GCP region option (Python)
URL: https://github.com/apache/beam/pull/9868#discussion_r338720101
##########
File path: sdks/python/apache_beam/options/pipeline_options.py
##########
@@ -500,6 +501,32 @@ def _add_argparse_args(cls, parser):
choices=['COST_OPTIMIZED', 'SPEED_OPTIMIZED'],
help='Set the Flexible Resource Scheduling mode')
+ def _get_default_gcp_region():
+ """Get a default value for Google Cloud region according to
+ https://cloud.google.com/compute/docs/gcloud-compute/#default-properties.
+ If no other default can be found, returns 'us-central1'.
+ """
+ environment_region = os.environ.get('CLOUDSDK_COMPUTE_REGION')
+ if environment_region:
+ logging.info('Using default GCP region %s from $CLOUDSDK_COMPUTE_REGION',
+ environment_region)
+ return environment_region
+ try:
+ cmd = ['gcloud', 'config', 'get-value', 'compute/region']
+ output = subprocess.check_output(cmd).decode('utf-8').strip()
+ if '(unset)' not in output:
+ logging.info('Using default GCP region %s from `%s`',
+ output, ' '.join(cmd))
+ return output
+ except subprocess.CalledProcessError:
+ pass
+ logging.warning(
+ '--region not set; will default to us-central1. Future releases of '
+ 'Beam will require the user to set --region explicitly, or else have a
'
+ 'default set via the gcloud tool. '
+ 'https://cloud.google.com/compute/docs/regions-zones')
+ return 'us-central1'
Review comment:
Actually it makes sense with the warning above. Yes, we can default for now
and will change in the future.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 333631)
Time Spent: 0.5h (was: 20m)
> Get default GCP region from gcloud
> ----------------------------------
>
> Key: BEAM-8472
> URL: https://issues.apache.org/jira/browse/BEAM-8472
> Project: Beam
> Issue Type: Improvement
> Components: runner-dataflow
> Reporter: Kyle Weaver
> Assignee: Kyle Weaver
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Currently, we default to us-central1 if --region flag is not set. The Google
> Cloud SDK generally tries to get a default value in this case for
> convenience, which we should follow.
> [https://cloud.google.com/compute/docs/gcloud-compute/#order_of_precedence_for_default_properties]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)