Skip to content

Commit

Permalink
update initialClusterVersion to 1.7.11-gke.1
Browse files Browse the repository at this point in the history
- addressing kubeflow#268
- previously thought GCS read/write was also necessary for tensorflow/agents
  but does not appear to be the case so oauthScopes left unchanged.
  • Loading branch information
cwbeitel committed Jan 7, 2018
1 parent 190394d commit c41d9fb
Showing 1 changed file with 52 additions and 44 deletions.
96 changes: 52 additions & 44 deletions py/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
import tempfile
import time

from google.cloud import storage # pylint: disable=no-name-in-module
from googleapiclient import discovery
from kubernetes import client as k8s_client

from googleapiclient import discovery
from google.cloud import storage # pylint: disable=no-name-in-module
from py import test_util, util

from py import test_util
from py import util

def setup(args):
"""Setup a GKE cluster for TensorFlow jobs.
Expand All @@ -34,18 +33,18 @@ def setup(args):
machine_type = "n1-standard-8"

cluster_request = {
"cluster": {
"name": cluster_name,
"cluster": {
"name": cluster_name,
"description": "A GKE cluster for TF.",
"initialNodeCount": 1,
"nodeConfig": {
"machineType": machine_type,
"machineType": machine_type,
"oauthScopes": [
"https://www.googleapis.com/auth/cloud-platform",
],
},
"https://www.googleapis.com/auth/cloud-platform",
],
},
# TODO(jlewi): Stop pinning GKE version once 1.8 becomes the default.
"initialClusterVersion": "1.8.1-gke.1",
"initialClusterVersion": "1.7.11-gke.1",
}
}

Expand All @@ -57,8 +56,8 @@ def setup(args):
for accelerator_spec in args.accelerators:
accelerator_type, accelerator_count = accelerator_spec.split("=", 1)
cluster_request["cluster"]["nodeConfig"]["accelerators"].append(
{"acceleratorCount": accelerator_count,
"acceleratorType": accelerator_type, })
{"acceleratorCount": accelerator_count,
"acceleratorType": accelerator_type, })

util.create_cluster(gke, project, zone, cluster_request)

Expand All @@ -70,6 +69,10 @@ def setup(args):

util.setup_cluster(api_client)

# A None gcs_client should be passed to test_util.create_junit_xml_file
# unless chart.startswith("gs://"), e.g. https://storage.googleapis.com/...
gcs_client = None

if chart.startswith("gs://"):
remote = chart
chart = os.path.join(tempfile.gettempdir(), os.path.basename(chart))
Expand Down Expand Up @@ -97,6 +100,7 @@ def setup(args):
t.class_name = "GKE"
test_util.create_junit_xml_file([t], args.junit_path, gcs_client)


def test(args):
"""Run the tests."""
gcs_client = storage.Client(project=args.project)
Expand All @@ -117,6 +121,7 @@ def test(args):
t.class_name = "GKE"
test_util.create_junit_xml_file([t], args.junit_path, gcs_client)


def teardown(args):
"""Teardown the resources."""
gke = discovery.build("container", "v1")
Expand All @@ -126,69 +131,71 @@ def teardown(args):
zone = args.zone
util.delete_cluster(gke, cluster_name, project, zone)


def add_common_args(parser):
"""Add common command line arguments to a parser.
Args:
parser: The parser to add command line arguments to.
"""
parser.add_argument(
"--project",
default=None,
type=str,
help=("The project to use."))
"--project",
default=None,
type=str,
help=("The project to use."))
parser.add_argument(
"--cluster",
default=None,
type=str,
help=("The name of the cluster."))
"--cluster",
default=None,
type=str,
help=("The name of the cluster."))
parser.add_argument(
"--zone",
default="us-east1-d",
type=str,
help=("The zone for the cluster."))
"--zone",
default="us-east1-d",
type=str,
help=("The zone for the cluster."))

parser.add_argument(
"--junit_path",
default="",
type=str,
help="Where to write the junit xml file with the results.")
"--junit_path",
default="",
type=str,
help="Where to write the junit xml file with the results.")


def main(): # pylint: disable=too-many-locals
logging.getLogger().setLevel(logging.INFO) # pylint: disable=too-many-locals
logging.getLogger().setLevel(logging.INFO) # pylint: disable=too-many-locals
# create the top-level parser
parser = argparse.ArgumentParser(
description="Setup clusters for testing.")
description="Setup clusters for testing.")
subparsers = parser.add_subparsers()

#############################################################################
# setup
#
parser_setup = subparsers.add_parser(
"setup",
"setup",
help="Setup a cluster for testing.")

parser_setup.add_argument(
"--accelerator",
dest="accelerators",
action="append",
help="Accelerator to add to the cluster. Should be of the form type=count.")
"--accelerator",
dest="accelerators",
action="append",
help="Accelerator to add to the cluster. Should be of the form type=count.")

parser_setup.set_defaults(func=setup)
add_common_args(parser_setup)

parser_setup.add_argument(
"--chart",
type=str,
required=True,
help="The path for the helm chart.")
"--chart",
type=str,
required=True,
help="The path for the helm chart.")

#############################################################################
# test
#
parser_test = subparsers.add_parser(
"test",
help="Run the tests.")
"test",
help="Run the tests.")

parser_test.set_defaults(func=test)
add_common_args(parser_test)
Expand All @@ -197,14 +204,15 @@ def main(): # pylint: disable=too-many-locals
# teardown
#
parser_teardown = subparsers.add_parser(
"teardown",
help="Teardown the cluster.")
"teardown",
help="Teardown the cluster.")
parser_teardown.set_defaults(func=teardown)
add_common_args(parser_teardown)

# parse the args and call whatever function was selected
args = parser.parse_args()
args.func(args)


if __name__ == "__main__":
main()

0 comments on commit c41d9fb

Please sign in to comment.