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

Musicbox needs to provide a default filename #237

Closed
K20shores opened this issue Sep 10, 2024 · 0 comments
Closed

Musicbox needs to provide a default filename #237

K20shores opened this issue Sep 10, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@K20shores
Copy link
Collaborator

The -o option right now always needs a filename.

Only specifying a directory produces an error

:: music_box -o output/ -e FlowTube
Traceback (most recent call last):                                                                                                                                                                                                  
  File "/opt/homebrew/anaconda3/envs/musicbox/bin/music_box", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/anaconda3/envs/musicbox/lib/python3.12/site-packages/acom_music_box/main.py", line 161, in main
    result = myBox.solve(musicBoxOutputPath)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/musicbox/lib/python3.12/site-packages/acom_music_box/music_box.py", line 238, in solve
    raise ValueError(f"Invalid output path: '{output_path}' does not contain a filename.")
ValueError: Invalid output path: 'output/' does not contain a filename.

Acceptance criteria

  • All of these commands work
    • music_box -o output/ -e FlowTube
    • music_box -o output.csv -e FlowTube
    • music_box -o output/results.csv -e FlowTube

Ideas

  • Provide a default output filename in the argparse declaration
    parser.add_argument(
    '-o', '--output',
    type=str,
    help='Path to save the output file, including the file name. If not provided, result will be printed to the console.'
    )
  • Likely will need to modify the output code, which we should maybe remove from the the solve function
    if output_path is not None:
    # Check if the output_path is a full path or just a file name
    if os.path.dirname(output_path) == '':
    # If output_path is just a filename, use the current directory
    output_path = os.path.join(os.getcwd(), output_path)
    elif not os.path.basename(output_path):
    raise ValueError(f"Invalid output path: '{output_path}' does not contain a filename.")
    # Ensure the directory exists
    dir_path = os.path.dirname(output_path)
    if dir_path and not os.path.exists(dir_path):
    os.makedirs(dir_path, exist_ok=True)
    df.to_csv(output_path, index=False)
@K20shores K20shores added the bug Something isn't working label Sep 10, 2024
@K20shores K20shores added this to the Sancy's MusicBox Paper milestone Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants