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

Add Datacard.segment_duration_distribution #95

Merged
merged 3 commits into from
Jul 26, 2024

Conversation

hagenw
Copy link
Member

@hagenw hagenw commented Jul 10, 2024

Makes use of audbcards.Dataset.segments and audbcards.Dataset.segment_durations, introduced in #31 to add audbcards.Datacard.segment_duration_distribution.

API documentation

image

Example dataset page

image

@hagenw hagenw marked this pull request as draft July 10, 2024 14:04
@hagenw hagenw force-pushed the datacard-segment-distribution branch from 4d70293 to 499f41a Compare July 10, 2024 14:36
@hagenw hagenw force-pushed the datacard-segment-distribution branch from 499f41a to 83da894 Compare July 22, 2024 09:09
@hagenw hagenw force-pushed the datacard-segment-distribution branch from 83da894 to f871fa1 Compare July 24, 2024 13:29
@hagenw hagenw marked this pull request as ready for review July 24, 2024 13:31
@hagenw hagenw changed the title Add Datacard.segment_duration_distribution() Add Datacard.segment_duration_distribution Jul 24, 2024
Copy link
Member

@ChristianGeng ChristianGeng left a comment

Choose a reason for hiding this comment

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

In order to produce a review for this issue, I have limited myself to building the documentation. The code builds flawlessly. I can render the documentation, and indeed, the public datasets contain a database that has segments - vadtoolkit which is pleasant to work with. For now I see this enough as a functional check.

There are two minor things that made me wonder:

1. convention of html-build location

I ususally expect locally built documentation in build/html/. For this project it deviates and is now at build/sphinx/html/. Have the conventions changed?
Or is this a one off?

2. Check of produced documentation file paths - sphinx-src-dir

  • the location of segment distribution files in cache pans out: /.cache/audbcards/vadtoolkit/1.1.0/vadtoolkit-1.1.0-segment-duration-distribution.png foolows the filename convention in the documentation, and the location in <cache-root>/<dataset-name>/<dataset-version>/ is also correct.

  • the location of the image file in sphinx-src- dir I find more difficulat. Within sphinx-src-dir I have this file: ~/work/tools-public/audbcards/build/sphinx/html/_images/vadtoolkit-1.1.0-segment-duration-distribution.png.
    What would the variables in <sphinx-src-dir>/<path><dataset-name>/ need to be expanded to in order to get this valid?

@hagenw
Copy link
Member Author

hagenw commented Jul 25, 2024

1. convention of html-build location

You are correct, if asked I would recommend the following command to build the docs:

$ python -m sphinx docs/ build/html -b html

I think the old build/sphinx/html that is mentioned in CONTRIBUTING.rst stems from an earlier version, that we siomply copy and pasted from other projects, e.g. in audb it is also present.

I created #102 to change this for audbcards.

@hagenw
Copy link
Member Author

hagenw commented Jul 25, 2024

2. Check of produced documentation file paths - sphinx-src-dir

Within sphinx-src-dir I have this file: ~/work/tools-public/audbcards/build/sphinx/html/_images/vadtoolkit-1.1.0-segment-duration-distribution.png.
What would the variables in `//`` need to be expanded to in order to get this valid?

What do you mean by the last sentence?

@ChristianGeng
Copy link
Member

2. Check of produced documentation file paths - sphinx-src-dir

Within sphinx-src-dir I have this file: ~/work/tools-public/audbcards/build/sphinx/html/_images/vadtoolkit-1.1.0-segment-duration-distribution.png.
What would the variables in `//`` need to be expanded to in order to get this valid?

What do you mean by the last sentence?

This was a backtick error:
<sphinx-src-dir>/<path><dataset-name>/ was intended between //

@hagenw
Copy link
Member Author

hagenw commented Jul 25, 2024

2. Check of produced documentation file paths - sphinx-src-dir

We start from cache at the position you located correctly: ~/.cache/audbcards/vadtoolkit/1.1.0/vadtoolkit-1.1.0-segment-duration-distribution.png. Then we copy the file into the documentation source folder with

image_file = audeer.path(
self.sphinx_src_dir,
self.path,
self.dataset.name,
file_name,
)
audeer.mkdir(os.path.dirname(image_file))
shutil.copyfile(cache_file, image_file)

Which means it will be located at ./docs/data-public/vadtoolkit/vadtoolkit-1.1.0-segment-duration-distribution.png, whereby data-public is given by the audbcards_datasets entry in docs/conf.py.

sphinx will then copy the file to the build/html/_images folder when building the documentation, and sets the links in the resulting HTML pages accordingly (this is the default sphinx behavior, we do not force it to do this). At the end, sphinx will also clean up the docs/ folder by deleting all files it has created in between:

# Delete auto-generated data card output folder
sections = app.config.audbcards_datasets
for path, _, _, _ in sections:
datacard_path = audeer.path(app.srcdir, path)
audeer.rmdir(datacard_path)
for ext in ["rst", "csv"]:
file = audeer.path(app.srcdir, f"{path}.{ext}")
if os.path.exists(file):
os.remove(file)

This means, you will not find ./docs/data-public/vadtoolkit/vadtoolkit-1.1.0-segment-duration-distribution.png.

@hagenw hagenw merged commit 84b909f into main Jul 26, 2024
10 checks passed
@hagenw hagenw deleted the datacard-segment-distribution branch July 26, 2024 14:26
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