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

update rename ~/.benchmark to ~/.osb and add symlink #721

Closed
wants to merge 4 commits into from
Closed
Changes from 2 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
20 changes: 19 additions & 1 deletion osbenchmark/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,25 @@

def benchmark_confdir():
default_home = os.path.expanduser("~")
return os.path.join(os.getenv("BENCHMARK_HOME", default_home), ".benchmark")
old_path = os.path.join(default_home, ".benchmark")
new_path = os.path.join(default_home, ".osb")

# Create .benchmark directory if it doesn't exist
if not os.path.exists(old_path):
os.makedirs(old_path, exist_ok=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can reuse the ensure_dir() from utils.

def ensure_dir(directory, mode=0o777):
    """
    Ensure that the provided directory and all of its parent directories exist.
    This function is safe to execute on existing directories (no op).

    :param directory: The directory to create (if it does not exist).
    :param mode: The permission flags to use (if it does not exist).
    """
    if directory:
        os.makedirs(directory, mode, exist_ok=True)


# Create .osb directory if it doesn't exist
if not os.path.exists(new_path):
os.makedirs(new_path, exist_ok=True)

# Create symlink from .osb to .benchmark if it doesn't exist
if not os.path.islink(new_path):
try:
os.symlink(old_path, new_path, target_is_directory=True)
except OSError:
print(f"Warning: Failed to create symlink from {new_path} to {old_path}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we also output the exact error?


return 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.

If the .benchmark directory does not exist, you will need to create it, so both are present in all cases.



def benchmark_root():
Expand Down
Loading