Skip to content

Generate HTML Landing Page and Add tests for all-ranks-html CLI flag #122

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

Merged
merged 7 commits into from
Jul 17, 2025

Conversation

skarjala
Copy link
Contributor

Summary:

  • Generate HTML landing Page

  • Respect --no-browser in multi-rank mode

  • Add four new CLI tests covering:
    Standard multi-rank HTML generation
    Suppressing browser launch (--no-browser)
    Mutually-exclusive flag error (--latest + --all-ranks-html)
    Empty-directory error path

skarjala added 2 commits July 15, 2025 21:13
Summary:

- Generate HTML landing Page
- Respect --no-browser in multi-rank mode
- Add four new CLI tests covering:
  - Standard multi-rank HTML generation
  - Suppressing browser launch (--no-browser)
  - Mutually-exclusive flag error (--latest + --all-ranks-html)
  - Empty-directory error path
@skarjala skarjala marked this pull request as ready for review July 16, 2025 04:33
@skarjala skarjala requested review from xmfan and yushangdi July 16, 2025 04:33
Copy link
Member

@xmfan xmfan left a comment

Choose a reason for hiding this comment

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

solid first revision

src/cli.rs Outdated
Comment on lines 226 to 233
let mut sorted_ranks: Vec<String> =
rank_logs.iter().map(|(_, rank)| rank.to_string()).collect();
sorted_ranks.sort_by(|a, b| {
a.parse::<u32>()
.unwrap_or(0)
.cmp(&b.parse::<u32>().unwrap_or(0))
});

Copy link
Member

@xmfan xmfan Jul 16, 2025

Choose a reason for hiding this comment

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

rank_logs is a Vec<(std::path::PathBuf, u32)>, where rank is u32 already at the start. So it's very likely that the rank.parse::<u32>() are avoidable.

You need a Vec<String> to pass to generate_multi_rank_html, but do you need it before sorting the ranks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll convert to String only when building the list for generate_multi_rank_html. Do you mean like this?

    let mut rank_nums: Vec<u32> = rank_logs.iter().map(|(_, rank)| *rank).collect();
    rank_nums.sort_unstable();
    let sorted_ranks: Vec<String> = rank_nums.iter().map(|r| r.to_string()).collect();

Copy link
Member

Choose a reason for hiding this comment

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

that's fine

Comment on lines 1 to 3
use assert_cmd::prelude::*;
use assert_cmd::Command as AssertCommand;
use predicates::prelude::*;
Copy link
Member

@xmfan xmfan Jul 16, 2025

Choose a reason for hiding this comment

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

nit: it's generally a bad practice to import more than what you need, and especially bad practice to import ::*. but prelude in rust is a curated subset and potentially more acceptable.

I personally still don't like it, it increases our chances one day of defining a function name that's already used by those libraries, and get hit with an unexpected compile error. It also makes it harder for people unfamiliar with rust to look at this file, and know where each function is implemented.

I'd favor individually importing functions/classes, especially if we only need a few like <5.

Copy link
Contributor Author

@skarjala skarjala Jul 16, 2025

Choose a reason for hiding this comment

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

Found the specific ones, I'll fix it.

use assert_cmd::Command;
use predicates::boolean::PredicateBooleanExt;
use predicates::str;

@@ -1,6 +1,11 @@
use assert_cmd::prelude::*;
use assert_cmd::Command as AssertCommand;
Copy link
Member

Choose a reason for hiding this comment

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

why are we aliasing it? generally it's not a good idea, especially not for standard utilities that many people will know as Command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 447 to 449
assert!(rank0_index.exists(), "rank 0 index.html should exist");
assert!(rank1_index.exists(), "rank 1 index.html should exist");
assert!(landing_page.exists(), "toplevel index.html should exist");
Copy link
Member

Choose a reason for hiding this comment

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

this must have been tedious lol, btw you don't always need to provide a custom error message to assert!. The default error message shows something like assertion failed: rank0_index.exists() which is basically your message. it's okay to keep the messages, but they can become a hassle to maintain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Co-authored-by: Simon Fan <[email protected]>
src/lib.rs Outdated
@@ -22,6 +22,8 @@ pub mod parsers;
mod templates;
mod types;

pub use crate::templates::{CSS, TEMPLATE_MULTI_RANK_INDEX, TEMPLATE_QUERY_PARAM_SCRIPT};
Copy link
Member

Choose a reason for hiding this comment

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

you don't need this import, we use crate::templates::*; above

@skarjala skarjala requested a review from xmfan July 16, 2025 17:02
@skarjala skarjala merged commit 479502c into pytorch:main Jul 17, 2025
16 checks passed
@skarjala skarjala deleted the pr1-htmlpage branch July 17, 2025 16:54
@StrongerXi
Copy link

Would be great to have a screenshot here in the comments to show the rendering.

@skarjala skarjala restored the pr1-htmlpage branch July 17, 2025 16:58
Copy link

@StrongerXi StrongerXi left a comment

Choose a reason for hiding this comment

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

Looks good!

@skarjala
Copy link
Contributor Author

Screenshot 2025-07-17 at 9 59 47 AM

@skarjala skarjala deleted the pr1-htmlpage branch July 17, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants