-
Notifications
You must be signed in to change notification settings - Fork 76
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
New CLI options #243
base: master
Are you sure you want to change the base?
New CLI options #243
Conversation
WalkthroughThe changes introduce a new command in the benchmark group that enables packaging of experiments by configuring Docker image tag prefixes and determining function names. Additionally, logging details have been added to cache update methods for improved traceability. A new method in the deployment system now builds functions with language version verification and default naming. A standalone script for updating Docker images, which parses CLI arguments, reads JSON configuration, and selectively pulls images based on their SHA, has also been added. The existing process command remains unchanged. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant S as sebs.py (package command)
participant C as sebs_client
participant E as Experiment Config
participant D as Deployment Client (build_function)
U->>S: Invoke "package" command with benchmark, function_name, image_tag_prefix, kwargs
S->>C: Update configuration (apply image_tag_prefix if provided)
S->>E: Retrieve experiment configuration and update benchmark
E-->>S: Return benchmark data
S->>D: Call build_function (with benchmark object and function name)
D->>D: Check language version and determine default function name (if missing)
D->>D: Build function using package_code method
D-->>S: Return build result
S-->>U: Output command result
sequenceDiagram
participant U as User
participant T as update_docker_images.py
participant A as Argparse Parser
participant J as JSON Config
participant P as Pull Functions
U->>T: Execute script with CLI arguments
T->>A: Parse deployment type, image type, language, and version
T->>J: Read Docker repository configuration data
T->>P: Iterate over systems & invoke pull functions (generic_pull, pull_function, pull_language)
P->>P: Compare image SHA to decide update necessity
P-->>T: Return update status (updated or up-to-date)
T-->>U: Output final image update status
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (4)
tools/update_docker_images.py (4)
1-23
: Use context manager for file operations.The script should use a context manager when opening files to ensure they are properly closed even if an exception occurs.
-config = json.load(open(os.path.join(PROJECT_DIR, "config", "systems.json"), "r")) +with open(os.path.join(PROJECT_DIR, "config", "systems.json"), "r") as f: + config = json.load(f)🧰 Tools
🪛 Ruff (0.8.2)
20-20: Use a context manager for opening files
(SIM115)
82-85
: Simplify conditional logic.The conditional statements for checking language version can be simplified using the logical OR operator.
- 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]) + if args.language_version is None or args.language_version == version: + configs.append([version, base_image])🧰 Tools
🪛 Ruff (0.8.2)
82-85: Combine
if
branches using logicalor
operatorCombine
if
branches(SIM114)
114-118
: Unused loop variable in nested loop.The
image_config
variable is not used within the loop body.- for image_type, image_config in system_config["images"].items(): + for image_type, _ in system_config["images"].items():🧰 Tools
🪛 Ruff (0.8.2)
116-116: Loop control variable
image_config
not used within loop bodyRename unused
image_config
to_image_config
(B007)
53-70
: Consider making benchmarks configuration more maintainable.The hardcoded benchmark list could become difficult to maintain as more benchmarks are added. Consider loading this from a configuration file or creating a function to discover available benchmarks.
For example, you could load this from a JSON configuration file or use a directory structure to discover benchmarks automatically.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
sebs.py
(1 hunks)sebs/cache.py
(2 hunks)sebs/faas/system.py
(1 hunks)tools/update_docker_images.py
(1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
tools/update_docker_images.py
20-20: Use a context manager for opening files
(SIM115)
82-85: Combine if
branches using logical or
operator
Combine if
branches
(SIM114)
116-116: Loop control variable image_config
not used within loop body
Rename unused image_config
to _image_config
(B007)
sebs.py
351-351: Local variable func
is assigned to but never used
Remove assignment to unused variable func
(F841)
🔇 Additional comments (5)
sebs/cache.py (2)
225-226
: Good addition of logging information.Adding this log statement improves traceability by providing visibility into code package updates. This will help with debugging cache operations.
271-271
: Good consistency in logging.This log message maintains consistency with the one added in
add_code_package
method, providing clear information about cache operations.sebs.py (1)
310-355
: The newpackage
command is well-structured.The implementation follows the same pattern as other commands and reuses the common parameter handling logic, which is good for consistency.
🧰 Tools
🪛 Ruff (0.8.2)
351-351: Local variable
func
is assigned to but never usedRemove assignment to unused variable
func
(F841)
sebs/faas/system.py (1)
185-201
: Good addition of thebuild_function
method.This method extracts common functionality from
get_function
, promoting code reuse. The implementation includes proper error handling and makes good use of defaults.However, there's one issue to consider: unlike
get_function
which returns aFunction
object, this method doesn't return anything but assigns a value to a variable. This inconsistency might lead to confusion.def build_function(self, code_package: Benchmark, func_name: Optional[str] = None): + """ + Build a function from the given code package without creating it in the FaaS system. + + :param code_package: The benchmark code package + :param func_name: Optional name for the function, defaults to system-generated name + :return: The built function object + """ 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) + rebuilt, _ = code_package.build(self.package_code) + return func_nametools/update_docker_images.py (1)
24-42
: Good implementation of the image pulling function.The
pull
function correctly handles cases where an image doesn't exist and provides clear feedback about image updates. The error handling is appropriate for this use case.
func = deployment_client.build_function( | ||
benchmark_obj, | ||
function_name if function_name else deployment_client.default_function_name(benchmark_obj) | ||
) |
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.
The returned function variable is not used.
The build_function
result is assigned to func
but never used afterward.
Consider one of the following options:
- func = deployment_client.build_function(
+ deployment_client.build_function(
benchmark_obj,
function_name if function_name else deployment_client.default_function_name(benchmark_obj)
)
Or if you need to return the function to the user:
func = deployment_client.build_function(
benchmark_obj,
function_name if function_name else deployment_client.default_function_name(benchmark_obj)
)
+ sebs_client.logging.info(f"Successfully built function: {func.name}")
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
func = deployment_client.build_function( | |
benchmark_obj, | |
function_name if function_name else deployment_client.default_function_name(benchmark_obj) | |
) | |
deployment_client.build_function( | |
benchmark_obj, | |
function_name if function_name else deployment_client.default_function_name(benchmark_obj) | |
) |
🧰 Tools
🪛 Ruff (0.8.2)
351-351: Local variable func
is assigned to but never used
Remove assignment to unused variable func
(F841)
We added a script for updating Docker images, and a new CLI option to create build package without uploading.
Missing tasks
Summary by CodeRabbit
New Features
Chores