Skip to content

Analysis overwrite protection#276

Merged
mathieudpnt merged 12 commits into
Project-OSmOSE:mainfrom
Gautzilla:analysis-overwrite-protection
Sep 15, 2025
Merged

Analysis overwrite protection#276
mathieudpnt merged 12 commits into
Project-OSmOSE:mainfrom
Gautzilla:analysis-overwrite-protection

Conversation

@Gautzilla
Copy link
Copy Markdown
Contributor

@Gautzilla Gautzilla commented Sep 8, 2025

This PR introduces a ValueError raising when attempting to run an analysis which has already been ran:

dataset.run_analysis(
    Analysis(
        analysis_type=AnalysisType.AUDIO,
        data_duration=dataset.origin_dataset.duration / 10,
        name="my_analysis",
        sample_rate=24_000,
    )
)

"""
RUNNING THIS WOULD NOW RAISE AN ERROR
dataset.run_analysis(
    Analysis(
        analysis_type=AnalysisType.SPECTROGRAM,
        data_duration=dataset.origin_dataset.duration / 10,
        name="my_analysis",
        sample_rate=24_000,
        fft=ShortTimeFFT(hamming(1024), hop=1024, fs=24_000),
    )
"""

# We can either rename the analysis or delete the previous one:
dataset.delete_analysis("my_analysis")

dataset.run_analysis(
    Analysis(
        analysis_type=AnalysisType.SPECTROGRAM,
        data_duration=dataset.origin_dataset.duration / 10,
        name="my_analysis",
        sample_rate=24_000,
        fft=ShortTimeFFT(hamming(1024), hop=1024, fs=24_000),
    )
)

Renaming an analysis

Analyses can be renamed easily. All corresponding folders and files will be moved accordingly:

dataset.rename_analysis("my_analysis", "my_new_analysis")

@Gautzilla Gautzilla self-assigned this Sep 8, 2025
@Gautzilla Gautzilla marked this pull request as ready for review September 9, 2025 14:14
Copy link
Copy Markdown
Contributor

@mathieudpnt mathieudpnt left a comment

Choose a reason for hiding this comment

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

Dataset would need a rename method as well

@mathieudpnt mathieudpnt merged commit 254c500 into Project-OSmOSE:main Sep 15, 2025
1 check passed
@Gautzilla Gautzilla deleted the analysis-overwrite-protection branch September 15, 2025 12:08
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