aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tools/dockerfiles
diff options
context:
space:
mode:
authorGravatar Austin Anderson <angerson@google.com>2018-08-22 11:43:32 -0700
committerGravatar Austin Anderson <angerson@google.com>2018-08-22 11:43:32 -0700
commit273fce7024f031ab90f8af475f74d64cb6a185ec (patch)
tree72372a34b175e3bd3a819f8357606a862b956561 /tensorflow/tools/dockerfiles
parent41d36dea21dba7d65567250f4b47242128c05df2 (diff)
Cleaned up requests from gunan
Diffstat (limited to 'tensorflow/tools/dockerfiles')
-rw-r--r--tensorflow/tools/dockerfiles/Dockerfile15
-rw-r--r--tensorflow/tools/dockerfiles/README.md4
-rw-r--r--tensorflow/tools/dockerfiles/assembler.py30
-rw-r--r--tensorflow/tools/dockerfiles/bashrc19
-rw-r--r--tensorflow/tools/dockerfiles/spec.yml15
5 files changed, 75 insertions, 8 deletions
diff --git a/tensorflow/tools/dockerfiles/Dockerfile b/tensorflow/tools/dockerfiles/Dockerfile
index 1d0dc3247d..2798e83cb7 100644
--- a/tensorflow/tools/dockerfiles/Dockerfile
+++ b/tensorflow/tools/dockerfiles/Dockerfile
@@ -1,3 +1,18 @@
+# Copyright 2018 The TensorFlow Authors. 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+#
# TensorFlow Dockerfile Development Container
#
# You can use this image to quickly develop changes to the Dockerfile assembler
diff --git a/tensorflow/tools/dockerfiles/README.md b/tensorflow/tools/dockerfiles/README.md
index ed026c20a0..ea80e9feaa 100644
--- a/tensorflow/tools/dockerfiles/README.md
+++ b/tensorflow/tools/dockerfiles/README.md
@@ -30,7 +30,7 @@ machine. If you are confused, check out the [Docker run
documentation](https://docs.docker.com/engine/reference/run/).
```bash
-# A volume mount (-v) is optional but highly recommended, especially for Jupyter
+# Volume mount (-v) is optional but highly recommended, especially for Jupyter.
# User permissions (-u) are required if you use (-v).
# CPU-based images
@@ -63,5 +63,5 @@ $ docker build -t tf-assembler .
$ docker run --user $(id -u):$(id -g) -it -v $(pwd):/tf tf-assembler bash
# In the container...
-/tf $ python3 ./assembler.py -o dockerfiles -s spec.yml --validate
+/tf $ python3 ./assembler.py -o dockerfiles -s spec.yml
```
diff --git a/tensorflow/tools/dockerfiles/assembler.py b/tensorflow/tools/dockerfiles/assembler.py
index 8dd6cea720..eb8d876cca 100644
--- a/tensorflow/tools/dockerfiles/assembler.py
+++ b/tensorflow/tools/dockerfiles/assembler.py
@@ -1,3 +1,18 @@
+# Copyright 2018 The TensorFlow Authors. 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+
"""Assemble common TF Dockerfiles from many parts.
This script constructs TF's Dockerfiles by aggregating partial
@@ -34,8 +49,8 @@ flags.DEFINE_string(
flags.DEFINE_string(
'output_dir',
- 'dockerfiles', ('Path to an output directory for Dockerfiles. '
- 'Will be created if it doesn\'t exist.'),
+ './dockerfiles', ('Path to an output directory for Dockerfiles. '
+ 'Will be created if it doesn\'t exist.'),
short_name='o')
flags.DEFINE_string(
@@ -178,6 +193,7 @@ class TfDockerValidator(cerberus.Validator):
for partial in self.root_document.get('partials', dict()).values():
if value in partial.get('args', tuple()):
return
+
self._error(field, '{} is not an arg used in any partial.'.format(value))
@@ -209,7 +225,6 @@ def build_partial_description(partial_spec):
# Document each arg
for arg, arg_data in partial_spec.get('args', dict()).items():
-
# Wrap arg description with comment lines
desc = arg_data.get('desc', '( no description )')
desc = textwrap.fill(
@@ -230,6 +245,7 @@ def build_partial_description(partial_spec):
arg_data.get('default', '(unset)'),
arg_options)
lines.extend([arg_use, desc])
+
return '\n'.join(lines)
@@ -252,7 +268,6 @@ def construct_contents(partial_specs, image_spec):
"""
processed_partial_strings = []
for partial_name in image_spec['partials']:
-
# Apply image arg-defaults to existing arg defaults
partial_spec = copy.deepcopy(partial_specs[partial_name])
args = partial_spec.get('args', dict())
@@ -316,7 +331,6 @@ def construct_documentation(header, partial_specs, image_spec):
# Build documentation for each partial in the image
for partial in image_spec['partials']:
-
# Copy partial data for default args unique to this image
partial_spec = copy.deepcopy(partial_specs[partial])
args = partial_spec.get('args', dict())
@@ -365,6 +379,7 @@ def normalize_partial_args(partial_specs):
if not isinstance(value, dict):
new_value = {'default': value}
args[arg] = new_value
+
return partial_specs
@@ -410,8 +425,10 @@ def flatten_args_references(image_specs):
new_args.extend(image_specs[arg]['arg-defaults'])
else:
new_args.append(arg)
+
image_spec['arg-defaults'] = new_args
too_deep += 1
+
return image_specs
@@ -458,8 +475,10 @@ def flatten_partial_references(image_specs):
new_partials.append(partial)
else:
new_partials.extend(image_specs[partial['image']]['partials'])
+
image_spec['partials'] = new_partials
too_deep += 1
+
return image_specs
@@ -486,6 +505,7 @@ def construct_dockerfiles(tf_spec):
image_spec)
contents = construct_contents(partial_specs, image_spec)
names_to_contents[name] = '\n'.join([documentation, contents])
+
return names_to_contents
diff --git a/tensorflow/tools/dockerfiles/bashrc b/tensorflow/tools/dockerfiles/bashrc
index 7f54609e78..48cacf20f6 100644
--- a/tensorflow/tools/dockerfiles/bashrc
+++ b/tensorflow/tools/dockerfiles/bashrc
@@ -1,3 +1,19 @@
+# Copyright 2018 The TensorFlow Authors. 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ==============================================================================
+
export PS1="\[\e[31m\]tf-docker\[\e[m\] \[\e[33m\]\w\[\e[m\] > "
export TERM=xterm-256color
alias grep="grep --color=auto"
@@ -24,10 +40,11 @@ To avoid this, run the container by specifying your user's userid:
$ docker run -u \$(id -u):\$(id -g) args...
WARN
else
-cat <<EXPL
+ cat <<EXPL
You are running this container as user with ID $(id -u) and group $(id -g),
which should map to the ID and group for your user on the Docker host. Great!
EXPL
fi
+# Turn off colors
echo -e "\e[m"
diff --git a/tensorflow/tools/dockerfiles/spec.yml b/tensorflow/tools/dockerfiles/spec.yml
index 4d622c53d2..28bf9a55da 100644
--- a/tensorflow/tools/dockerfiles/spec.yml
+++ b/tensorflow/tools/dockerfiles/spec.yml
@@ -4,6 +4,21 @@
#
# This is commented-out and prepended to each generated Dockerfile.
header: |
+ Copyright 2018 The TensorFlow Authors. 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.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============================================================================
+
THIS IS A GENERATED DOCKERFILE.
This file was assembled from multiple pieces, whose use is documented