-
Notifications
You must be signed in to change notification settings - Fork 6
COD-1345: Do not gzip walltime reports #117
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
053bd0f
feat(upload): do not compress profile archive for walltime runs
adriencaccia 723fcec
feat(upload): add content encoding to upload metadata
adriencaccia 08a8a5d
refactor(upload): refactor profile-archive
adriencaccia 65a2980
refactor(run): store upload metadata latest version in a const
adriencaccia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| /target | ||
| .DS_Store | ||
| samples |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| mod interfaces; | ||
| mod profile_archive; | ||
| mod upload; | ||
| mod upload_metadata; | ||
|
|
||
| pub use interfaces::*; | ||
| pub use profile_archive::ProfileArchive; | ||
| pub use upload::upload; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| use base64::{Engine, engine::general_purpose}; | ||
|
|
||
| use crate::prelude::*; | ||
| use std::path::PathBuf; | ||
|
|
||
| #[derive(Debug)] | ||
| pub struct ProfileArchive { | ||
| pub hash: String, | ||
| pub content: ProfileArchiveContent, | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| pub enum ProfileArchiveContent { | ||
| CompressedInMemory { data: Vec<u8> }, | ||
| UncompressedOnDisk { path: PathBuf }, | ||
| } | ||
|
|
||
| impl ProfileArchive { | ||
| pub fn new_compressed_in_memory(data: Vec<u8>) -> Self { | ||
| let hash = general_purpose::STANDARD.encode(md5::compute(&data).0); | ||
| ProfileArchive { | ||
| hash, | ||
| content: ProfileArchiveContent::CompressedInMemory { data }, | ||
| } | ||
| } | ||
|
|
||
| pub fn new_uncompressed_on_disk(path: PathBuf) -> Result<Self> { | ||
| let metadata = std::fs::metadata(&path)?; | ||
| if !metadata.is_file() { | ||
| return Err(anyhow!("The provided path is not a file")); | ||
| } | ||
| let mut file = std::fs::File::open(&path)?; | ||
| let mut buffer = Vec::new(); | ||
| use std::io::Read; | ||
| file.read_to_end(&mut buffer)?; | ||
| let hash = general_purpose::STANDARD.encode(md5::compute(&buffer).0); | ||
| Ok(ProfileArchive { | ||
| hash, | ||
| content: ProfileArchiveContent::UncompressedOnDisk { path }, | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| impl ProfileArchiveContent { | ||
| pub async fn size(&self) -> Result<u64> { | ||
| match &self { | ||
| ProfileArchiveContent::CompressedInMemory { data } => Ok(data.len() as u64), | ||
| ProfileArchiveContent::UncompressedOnDisk { path } => { | ||
| let metadata = tokio::fs::metadata(path).await?; | ||
| Ok(metadata.len()) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub fn encoding(&self) -> Option<String> { | ||
| match self { | ||
| ProfileArchiveContent::CompressedInMemory { .. } => Some("gzip".to_string()), | ||
| _ => None, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Drop for ProfileArchiveContent { | ||
| fn drop(&mut self) { | ||
| if let ProfileArchiveContent::UncompressedOnDisk { path } = self { | ||
| if path.exists() { | ||
| let _ = std::fs::remove_file(path); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
would be great to find a way to have the retries even when streaming the body
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.
As seen in https://github.com/TrueLayer/reqwest-middleware/pull/51/files?w=1#diff-474abab8d90fcf4a3811b4faa74eff00faa8c9c190c9fd2e47991de8b2f4d64eR38-R49, it is not possible out of the box.
We will need to create a middleware manually that implements streaming. I will take a look