-
Notifications
You must be signed in to change notification settings - Fork 81
New CLI options #243
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
base: master
Are you sure you want to change the base?
New CLI options #243
Changes from all commits
6001c87
341f877
c33e023
db93817
a81cd27
b31a711
fbdcc3e
d7a85e3
5b01693
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -233,6 +233,23 @@ def update_function( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def build_function(self, code_package: Benchmark, func_name: Optional[str] = None): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if code_package.language_version not in self.system_config.supported_language_versions( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
self.name(), code_package.language_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
raise Exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Unsupported {language} version {version} in {system}!".format( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
language=code_package.language_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version=code_package.language_version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
system=self.name(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if not func_name: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func_name = self.default_function_name(code_package) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
code_package.build(self.package_code) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+236
to
+252
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. 🛠️ Refactor suggestion Missing return value for build result The method calls Return the build result to provide information to the caller: def build_function(self, code_package: Benchmark, func_name: Optional[str] = None):
if code_package.language_version not in self.system_config.supported_language_versions(
self.name(), code_package.language_name
):
# ...exception handling
if not func_name:
func_name = self.default_function_name(code_package)
- code_package.build(self.package_code)
+ return code_package.build(self.package_code) 📝 Committable suggestion
Suggested change
Architecture parameter missing in supported_language_versions check The implementation of This could lead to inconsistent behavior between the two methods. The Apply this fix: def build_function(self, code_package: Benchmark, func_name: Optional[str] = None):
if code_package.language_version not in self.system_config.supported_language_versions(
- self.name(), code_package.language_name
+ self.name(), code_package.language_name, code_package.architecture
):
raise Exception( 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
a) if a cached function with given name is present and code has not changed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
then just return function name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import docker | ||
import json | ||
import os | ||
from typing import Optional | ||
|
||
PROJECT_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.pardir) | ||
DOCKER_DIR = os.path.join(PROJECT_DIR, "dockerfiles") | ||
|
||
parser = argparse.ArgumentParser(description="Run local app experiments.") | ||
parser.add_argument( | ||
"--deployment", default=None, choices=["local", "aws", "azure", "gcp", "openwhisk"], action="store" | ||
) | ||
parser.add_argument("--type", default=None, choices=["build", "run", "manage", "function"], action="store") | ||
parser.add_argument("--language", default=None, choices=["python", "nodejs"], action="store") | ||
parser.add_argument("--language-version", default=None, type=str, action="store") | ||
args = parser.parse_args() | ||
config = json.load(open(os.path.join(PROJECT_DIR, "config", "systems.json"), "r")) | ||
repository = config["general"]["docker_repository"] | ||
client = docker.from_env() | ||
|
||
def pull(image_name): | ||
|
||
image_name = f'{repository}:{image_name}' | ||
previous_sha: Optional[str] | ||
try: | ||
img = client.images.get(image_name) | ||
previous_sha = img.attrs['Id'] | ||
except docker.errors.ImageNotFound: | ||
previous_sha = None | ||
print(f"Ignoring not present image: {image_name}") | ||
return | ||
|
||
img = client.images.pull(image_name) | ||
|
||
if img.attrs['Id'] != previous_sha: | ||
print(f"Updated image: {image_name}") | ||
else: | ||
print(f"Image up-to-date: {image_name}") | ||
|
||
def generic_pull(image_type, system, language=None, version=None): | ||
|
||
if language is not None and version is not None: | ||
image_name = f"{image_type}.{system}.{language}.{version}" | ||
else: | ||
image_name = f"{image_type}.{system}" | ||
|
||
pull(image_name) | ||
|
||
benchmarks = { | ||
"python": [ | ||
"110.dynamic-html", | ||
"120.uploader", | ||
"210.thumbnailer", | ||
"220.video-processing", | ||
"311.compression", | ||
"411.image-recognition", | ||
"501.graph-pagerank", | ||
"502.graph-mst", | ||
"503.graph-bfs", | ||
"504.dna-visualisation", | ||
], | ||
"nodejs": [ | ||
"110.dynamic-html", | ||
"120.uploader", | ||
"210.thumbnailer" | ||
] | ||
} | ||
|
||
def pull_function(image_type, system, language, language_version): | ||
|
||
for bench in benchmarks[language]: | ||
image_name = f"{image_type}.{system}.{bench}.{language}-{language_version}" | ||
pull(image_name) | ||
|
||
def pull_language(system, language, language_config): | ||
configs = [] | ||
if "base_images" in language_config: | ||
for version, base_image in language_config["base_images"].items(): | ||
if args.language_version is not None and args.language_version == version: | ||
configs.append([version, base_image]) | ||
elif args.language_version is None: | ||
configs.append([version, base_image]) | ||
else: | ||
configs.append([None, None]) | ||
|
||
for image in configs: | ||
if args.type is None: | ||
for image_type in language_config["images"]: | ||
|
||
if image_type == "function": | ||
pull_function(image_type, system, language, image[0]) | ||
else: | ||
generic_pull(image_type, system, language, image[0]) | ||
else: | ||
generic_pull(args.type, system, language, image[0]) | ||
|
||
|
||
def pull_systems(system, system_config): | ||
|
||
if args.type == "manage": | ||
if "images" in system_config: | ||
generic_pull(args.type, system) | ||
else: | ||
print(f"Skipping manage image for {system}") | ||
else: | ||
if args.language: | ||
pull_language(system, args.language, system_config["languages"][args.language]) | ||
else: | ||
for language, language_dict in system_config["languages"].items(): | ||
pull_language(system, language, language_dict) | ||
# Build additional types | ||
if "images" in system_config: | ||
for image_type, image_config in system_config["images"].items(): | ||
generic_pull(image_type, system) | ||
|
||
|
||
if args.deployment is None: | ||
for system, system_dict in config.items(): | ||
if system == "general": | ||
continue | ||
pull_systems(system, system_dict) | ||
else: | ||
pull_systems(args.deployment, config[args.deployment]) |
Uh oh!
There was an error while loading. Please reload this page.