Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/improve cli #111

Merged
merged 3 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions spot/Spot.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ def collect_data(self):
self.price_retriever.fetch_current_pricing()
self.last_log_timestamp = self.log_retriever.get_logs(self.last_log_timestamp)

def invoke(self, memory_mb):
return self.recommendation_engine.invoke_once(memory_mb)
def invoke(self, memory_mb, count):
for _ in range(count):
self.recommendation_engine.invoke_once(memory_mb)

def teardown(self):
# Just saving the Context for now.
Expand Down
7 changes: 4 additions & 3 deletions spot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def main():
"--fetch", "-f", action="store_true", help="Fetch log and config data from AWS"
)
parser.add_argument(
"--invoke", "-i", action="store_true", help="Invoke the function"
"--invoke", "-i", type=int, help="The number of times you invoke the function"
)
parser.add_argument(
"--memory_mb", "-m", type=int, help="Memory (MB) of the function"
Expand All @@ -51,14 +51,15 @@ def main():

spot = Spot(path, session)
if args.optimize:
spot.optimize()
opt = spot.optimize()
args.memory_mb = int(opt["Minimum Cost Memory"][0])
if args.fetch:
spot.collect_data()
if args.invoke:
if not args.memory_mb:
print("Please specify a memory value when invoking a function")
exit(1)
spot.invoke(args.memory_mb)
spot.invoke(args.memory_mb, args.invoke)

spot.teardown()

Expand Down