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

Fix workload parameter processing when a key is mapped to a JSON file #690

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

gkamat
Copy link
Collaborator

@gkamat gkamat commented Nov 6, 2024

Description

When the argument passed to the workload-params option includes a key-value pair, where the value is a JSON file, there parser may treat the entire option string incorrectly as a filename.

Issues Resolved

#502

Testing

Unit and integ tests. Added unit tests.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Collaborator

@IanHoang IanHoang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one comment but looks good to me

current_workload = self.read_workload(workload_name, workload_spec, mapping_dir)
try:
current_workload = self.read_workload(workload_name, workload_spec, mapping_dir)
except Exception as e:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We can use WorkloadConfigError from exceptions.py in place of the generic Exception class to be more descriptive.

# from exceptions.py
class WorkloadConfigError(BenchmarkError):
    """
    Thrown when something is wrong with the workload config e.g. user supplied a workload-param
    that can't be set
    """

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We can use WorkloadConfigError from exceptions.py in place of the generic Exception class to be more descriptive.

# from exceptions.py
class WorkloadConfigError(BenchmarkError):
    """
    Thrown when something is wrong with the workload config e.g. user supplied a workload-param
    that can't be set
    """

The reason Exception was used here is to catch all possible errors that might be raised by read_workload. For, instance, it might raise a WorkloadSyntaxError. However, it's correct that a wrapped WorkloadConfigError could be raised once the exception is caught. Will consider doing that in a future revision.

@gkamat gkamat merged commit 92f8102 into opensearch-project:main Nov 26, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants