This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Feature: spark init docker repo customization #358
Merged
jafreck
merged 7 commits into
Azure:master
from
jafreck:feature/spark-init-customization
Feb 7, 2018
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bf750b4
customize docker_repo based on init args
jafreck 5ba171a
whitespace
jafreck e23de71
add some docs
jafreck 149bf2f
Merge branch 'master' into feature/spark-init-customization
jafreck 7f25aed
r-base to r
jafreck 37d18b2
case insensitive r flag, typo fix
jafreck 6891540
Merge branch 'master' into feature/spark-init-customization
jafreck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import os | ||
import os | ||
import argparse | ||
import typing | ||
from distutils.dir_util import copy_tree | ||
|
@@ -8,14 +8,29 @@ | |
def setup_parser(parser: argparse.ArgumentParser): | ||
parser.add_argument('--global', dest='global_flag', action='store_true', | ||
help="Create a .aztk/ folder in your home directory for global configurations.") | ||
software_parser = parser.add_mutually_exclusive_group() | ||
software_parser.add_argument('--python', action="store_true", required=False) | ||
software_parser.add_argument('--r', '--R', action="store_true", required=False) | ||
software_parser.add_argument('--java', action="store_true", required=False) | ||
software_parser.add_argument('--scala', action="store_true", required=False) | ||
|
||
|
||
def execute(args: typing.NamedTuple): | ||
# software_specific init | ||
if args.python: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: good candidate for a switch statement. No need to change. |
||
docker_repo = constants.DEFAULT_SPARK_PYTHON_DOCKER_REPO | ||
elif args.r: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this need to change to args.r || args.R? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both |
||
docker_repo = constants.DEFAULT_SPARK_R_BASE_DOCKER_REPO | ||
else: | ||
docker_repo = constants.DEFAULT_DOCKER_REPO | ||
|
||
if args.global_flag: | ||
create_directory(constants.GLOBAL_INIT_DIRECTORY_DEST) | ||
create_directory(constants.GLOBAL_INIT_DIRECTORY_DEST, docker_repo) | ||
else: | ||
create_directory(constants.LOCAL_INIT_DIRECTORY_DEST) | ||
|
||
def create_directory(dest_path: str): | ||
create_directory(constants.LOCAL_INIT_DIRECTORY_DEST, docker_repo) | ||
|
||
|
||
def create_directory(dest_path: str, docker_repo: str): | ||
config_src_path = constants.INIT_DIRECTORY_SOURCE | ||
config_dest_path = dest_path | ||
|
||
|
@@ -29,3 +44,12 @@ def create_directory(dest_path: str): | |
|
||
if os.path.isfile(secrets_template_path) and not os.path.isfile(secrets_path): | ||
os.rename(secrets_template_path, secrets_path) | ||
|
||
cluster_path = os.path.join(dest_path, 'cluster.yaml') | ||
|
||
if os.path.isfile(cluster_path): | ||
with open(cluster_path, 'r') as stream: | ||
cluster_yaml = stream.read() | ||
cluster_yaml = cluster_yaml.replace("docker_repo: \n", "docker_repo: {}\n".format(docker_repo)) | ||
with open(cluster_path, 'w') as file: | ||
file.write(cluster_yaml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will it be confusing to users to split out java & scala? They're essentially the same thing and may leave customers wondering why we have split them out. Thoughts?
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.
No preference, just not sure how to word the flag if we combine them.
Under the hood,
--java
,--scala
and no flag all do the same thing.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.
yeah.. I just can't think of a word that combines them both, like .NET but for java... I was thinking 'default' but that doesn't seem right either.
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.
maybe just 'base'? and add some verbosity to the CLI and docs that this will use the out-of-the-box java/scale environment?