Skip to content

Commit 5d7f12b

Browse files
committed
switch to using prefix, fix some typos
1 parent 6c74d79 commit 5d7f12b

File tree

2 files changed

+34
-26
lines changed

2 files changed

+34
-26
lines changed

pywren/scripts/setupscript.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,24 @@ def validate_lambda_role_name(role_name):
8585
# FIXME
8686
return True
8787

88-
def ds(key):
89-
"""
90-
Debug suffix for defaults. For automated testing,
91-
automatically adds a suffix to each default
92-
"""
93-
env_var = 'PYWREN_SETUP_INTERACTIVE_DEBUG_SUFFIX'
94-
suffix = os.environ.get(env_var, "")
95-
return "{}{}".format(key, suffix)
96-
9788
@click.command()
9889
@click.option('--dryrun', default=False, is_flag=True, type=bool,
9990
help='create config file but take no actions')
91+
@click.option('--suffix', default="", type=str,
92+
help="suffix to use for all automatically-generated named entities, useful for helping with IAM roles, and automated testing")
10093
@click.pass_context
101-
def interactive_setup(ctx, dryrun):
94+
def interactive_setup(ctx, dryrun, suffix):
95+
96+
97+
def ds(key):
98+
"""
99+
Debug suffix for defaults. For automated testing,
100+
automatically adds a suffix to each default
101+
"""
102+
return "{}{}".format(key, suffix)
103+
102104

103-
click.echo("This is the pywren interactive setup script")
105+
click.echo("This is the PyWren interactive setup script")
104106
try:
105107
#first we will try and make sure AWS is set up
106108

@@ -109,8 +111,8 @@ def interactive_setup(ctx, dryrun):
109111
except Exception as e:
110112
raise
111113

112-
click.echo("This interactive script will set up your initial pywren configuration.")
113-
click.echo("If this is your first time using pywren then accepting the defaults should be fine")
114+
click.echo("This interactive script will set up your initial PyWren configuration.")
115+
click.echo("If this is your first time using PyWren then accepting the defaults should be fine.")
114116

115117
# first, what is your default AWS region?
116118
aws_region = click_validate_prompt("What is your default aws region?",
@@ -128,15 +130,15 @@ def interactive_setup(ctx, dryrun):
128130
validate_func=check_overwrite_function)
129131
config_filename = os.path.expanduser(config_filename)
130132

131-
s3_bucket = click_validate_prompt("pywren requires an s3 bucket to store intermediate data. What s3 bucket would you like to use?",
133+
s3_bucket = click_validate_prompt("PyWren requires an s3 bucket to store intermediate data. What s3 bucket would you like to use?",
132134
default=create_unique_bucket_name(),
133135
validate_func=check_valid_bucket_name)
134136
create_bucket = False
135137
if not check_bucket_exists(s3_bucket):
136138
create_bucket = click.confirm("Bucket does not currently exist, would you like to create it?", default=True)
137139

138-
click.echo("Pywren prefixes every object it puts in S3 with a particular prefix")
139-
bucket_pywren_prefix = click_validate_prompt("pywren s3 prefix: ",
140+
click.echo("PyWren prefixes every object it puts in S3 with a particular prefix.")
141+
bucket_pywren_prefix = click_validate_prompt("PyWren s3 prefix: ",
140142
default=pywren.wrenconfig.AWS_S3_PREFIX_DEFAULT,
141143
validate_func=validate_s3_prefix)
142144

@@ -154,8 +156,8 @@ def interactive_setup(ctx, dryrun):
154156
"What is your function name?",
155157
default=function_name,
156158
validate_func = validate_lambda_function_name)
157-
click.echo("pywren standalone mode uses dedicated AWS instances to run pywren tasks. This is more flexible, but more expensive with fewer simultaneous workers.")
158-
use_standalone = click.confirm("Would you like to enable pywren standalone mode?")
159+
click.echo("PyWren standalone mode uses dedicated AWS instances to run PyWren tasks. This is more flexible, but more expensive with fewer simultaneous workers.")
160+
use_standalone = click.confirm("Would you like to enable PyWren standalone mode?")
159161

160162
click.echo("Creating config {}".format(config_filename))
161163
ctx.obj = {"config_filename" : config_filename}
@@ -167,22 +169,22 @@ def interactive_setup(ctx, dryrun):
167169
bucket_prefix= bucket_pywren_prefix,
168170
force=True)
169171
if dryrun:
170-
click.echo("dryrun is set, not manipulating cloud state")
172+
click.echo("dryrun is set, not manipulating cloud state.")
171173
return
172174

173175
if create_bucket:
174-
click.echo("Creating bucket {}".format(s3_bucket))
176+
click.echo("Creating bucket {}.".format(s3_bucket))
175177
ctx.invoke(pywrencli.create_bucket)
176-
click.echo("Creating role")
178+
click.echo("Creating role.")
177179
ctx.invoke(pywrencli.create_role)
178-
click.echo("deploying lambda")
180+
click.echo("Deploying lambda.")
179181
ctx.invoke(pywrencli.deploy_lambda)
180182

181183
if use_standalone:
182-
click.echo("setting up standalone mode")
184+
click.echo("Setting up standalone mode.")
183185
ctx.invoke(pywrencli.create_queue)
184186
ctx.invoke(pywrencli.create_instance_profile)
185-
click.echo("pausing for 10 sec for changes to propoagate")
187+
click.echo("Pausing for 10 sec for changes to propoagate.")
186188
time.sleep(10)
187189
ctx.invoke(pywrencli.test_function)
188190

tests/test_cmdline.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def questions_to_string(q):
6262
def config_exists(filename):
6363
return os.path.exists(os.path.expanduser(filename))
6464

65+
66+
SUFFIX = os.environ.get("PYWREN_SETUP_INTERACTIVE_DEBUG_SUFFIX", "")
67+
6568
@cmdtest
6669
class InteractiveCMDDryrun(unittest.TestCase):
6770
"""
@@ -89,7 +92,8 @@ def test_basic_defaults_dryrun(self):
8992
qs['config_file'] = self.config_filename
9093

9194
cmd_str = questions_to_string(qs)
92-
result = self.runner.invoke(interactive_setup, ['--dryrun'],
95+
result = self.runner.invoke(interactive_setup,
96+
['--dryrun', '--suffix', SUFFIX],
9397
input=cmd_str)
9498
print(result.output)
9599
assert not result.exception
@@ -102,7 +106,8 @@ def test_bad_region(self):
102106
'ap-northeast-2']
103107

104108
cmd_str = questions_to_string(qs)
105-
result = self.runner.invoke(interactive_setup, ['--dryrun'],
109+
result = self.runner.invoke(interactive_setup,
110+
['--dryrun', '--suffix', SUFFIX],
106111
input=cmd_str)
107112
print(result.output)
108113
assert not result.exception
@@ -146,6 +151,7 @@ def test_basic_defaults(self):
146151

147152
cmd_str = questions_to_string(qs)
148153
result = self.runner.invoke(interactive_setup,
154+
args=['--suffix', SUFFIX],
149155
input=cmd_str)
150156
print(result.output)
151157
assert "Hello world" in result.output

0 commit comments

Comments
 (0)