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

Change OSB Config directory from ~/.benchmark to ~/.osb #732

Merged
merged 7 commits into from
Jan 21, 2025

Conversation

OVI3D0
Copy link
Member

@OVI3D0 OVI3D0 commented Jan 16, 2025

Description

Updates OSB's config directory to ~/.osb instead of ~/.benchmark. Also adds a symlink if the old path exists but the new one does not. 'benchmark' is an overloaded term, while using ~/.osb reduces ambiguity and is more consistent with the project's name.

Issues Resolved

#728

Testing

  • New functionality includes testing

make test + make it


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.

@OVI3D0 OVI3D0 marked this pull request as ready for review January 16, 2025 22:26

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.

Do you recall what the exact exception was? Let's try to use that one instead of a general Exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

It ended up being a FileNotFoundError, but not sure if it's worth changing to this exception since the latest commit includes a fix for that error. Lmk what you think though

Copy link
Collaborator

@IanHoang IanHoang Jan 17, 2025

Choose a reason for hiding this comment

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

Even if the FileNotFoundError was addressed with the fix to the Config class, we should still incorporate it as it's an error that happened and potentially could still occur in the future.

Also, it's best to not use the base Exception class since it technically violates the principle of least astonishment. Python's error handling is designed to be specific and meaningful and using base Exception goes against this design principle

# Ensure symlink from .osb to .benchmark
ensure_symlink(old_path, new_path)

final_path = os.path.join(os.getenv("BENCHMARK_HOME", default_home), ".osb")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: could be more descriptive with the variable name, would rename final_path to benchmark_confdir_path.

Comment on lines 47 to 54
f"Error type: {type(e).__name__}\n"
f"Error message: {str(e)}\n"
f"Current user: {os.getlogin()}\n"
f"Current working directory: {os.getcwd()}\n"
f"Python version: {sys.version}\n"
f"Operating system: {sys.platform}\n"
f"Permissions of {old_path}: {oct(os.stat(old_path).st_mode) if os.path.exists(old_path) else 'N/A'}\n"
f"Permissions of parent of {new_path}: {oct(os.stat(os.path.dirname(new_path)).st_mode)}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since these were primarily used for debugging integ tests, we can remove them

f"Permissions of {old_path}: {oct(os.stat(old_path).st_mode) if os.path.exists(old_path) else 'N/A'}\n"
f"Permissions of parent of {new_path}: {oct(os.stat(os.path.dirname(new_path)).st_mode)}"
)
print(error_message)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use console.print from utils?

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 some comments

Signed-off-by: Michael Oviedo <[email protected]>
@OVI3D0 OVI3D0 merged commit ec150c0 into opensearch-project:main Jan 21, 2025
10 checks passed
@OVI3D0 OVI3D0 deleted the osb-symlink branch January 21, 2025 18:27
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