-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: martian-pipestance crate #412
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this looks extremely useful. Mostly minor comments.
Was the intention to provide an executable that runs this?
@@ -0,0 +1,308 @@ | |||
//! | |||
//! Critical path in the pipestance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to flesh out this docstring a little bit to make it clear exactly what we're talking about here.
weight_function, | ||
)) | ||
} | ||
pub fn compute(final_state: &FinalState, perf: &Perf, weight_function: StageWeight) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bikeshedding but this is kind of just a constructor so new
is probably the conventional name.
|
||
fn new() -> Self { | ||
Self::default() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Providing new
when we already derive Default
isn't necessary IMHO.
fn new() -> Self { | |
Self::default() | |
} |
} | ||
} | ||
|
||
fn _critical_path(mut self) -> CriticalPath { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leading underscore method names aren't idiomatic in Rust; even then, this method is called and is already marked private.
fn _critical_path(mut self) -> CriticalPath { | |
fn critical_path(mut self) -> CriticalPath { |
let critical_path = | ||
CriticalPath::compute(&final_state, &perf, StageWeight::NoQueueWallTime); | ||
|
||
println!("{:#?}", critical_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please address the few clippy warnings?
use serde::de::DeserializeOwned; | ||
use std::path::Path; | ||
|
||
pub mod common; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make more sense to move the things in common
into the crate root and mark them pub(crate)
.
@@ -0,0 +1,26 @@ | |||
use anyhow::{Context, Result}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this crate should expose an explicit API by pub use
ing the relevant types/functions.
pub mod critical_path; | ||
pub mod final_state; | ||
pub mod perf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these actually be pub
or should we re-export the relevant pieces?
/// A file associated with a martian pipestance such as _perf, _finalstate etc | ||
/// that can be deserialized into a concrete type | ||
pub trait PipestanceFile: DeserializeOwned { | ||
fn filename() -> &'static str; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is 'static
you might as well make this a const
member instead of a method, unless we think this will need to be dynamically dispatched in certain cases.
fn from_string(file_contents: String) -> Result<Self> { | ||
Ok(serde_json::from_str(&file_contents)?) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is actually parsing JSON, it should probably be named accordingly. Also, it doesn't need to take ownership of the input.
fn from_string(file_contents: String) -> Result<Self> { | |
Ok(serde_json::from_str(&file_contents)?) | |
} | |
fn from_json(file_contents: &str) -> Result<Self> { | |
Ok(serde_json::from_str(file_contents)?) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a really bad idea to reinvent this wheel. There's a lot of subtitles that need to be gotten right. We already have code to do all of this.
It also probably shouldn't be part of the martian-lang/martian-rust
repo, which is all about support for writing stage code in rust.
@@ -3,3 +3,4 @@ martian-filetypes/example.bincode | |||
martian-filetypes/example.json | |||
martian-filetypes/example_lazy.bincode | |||
martian-filetypes/example_lazy.json | |||
.DS_Store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline at end of file please.
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
serde = { version = "1.0", features = ['derive'] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be consistent about which quotes to use.
I'm going to close this PR. It doesn't belong in this repo, it doesn't product correct output, and it's redundant with existing code we have elsewhere. |
@adam-azarchs can you please link this PR to the aforementioned existing code for our current edification/posterity? |
I am okay not including the critical path code here, but it makes sense to have the struct definitions for perf and finalstate in this repo. |
Why? Nothing using this repo should be touching top-level pipestance state like that. |
So I see library code there, but is there an existing executable to output the critical path from _perf data? If not, at least some guidance to how to fit the existing pieces together would probably be useful. |
Yes, but they needed a bit of maintenance; see the (private repo) PRs I sent you. |
_perf
and_finalstate
file. Code mostly copied from Logan's crate