Skip to content

Commit

Permalink
Display the artifact file suffix/type in the "db jobs" output
Browse files Browse the repository at this point in the history
This adds a new column ("Type") to the table that "butido db jobs"
outputs. It works under the assumption that the artifact file names
indicate the type of artifact via a file name extension [0] (i.e., using
the format "{name}.{type}").
The fallback values are "-" if no artifact is available (build failures,
aborted jobs, etc. - that's also why we're using LEFT JOIN) or "?" (for
unknown) if no file name extension was detected.

This resolves science-computing#391.

[0]: https://en.wikipedia.org/wiki/Filename_extension

Signed-off-by: Michael Weiss <[email protected]>
  • Loading branch information
primeos-work committed Sep 13, 2024
1 parent cc35c20 commit e446e2f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/commands/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ fn jobs(
) -> Result<()> {
let csv = matches.get_flag("csv");
let hdrs = crate::commands::util::mk_header(vec![
"Submit", "Job", "Time", "Host", "Ok?", "Package", "Version", "Distro",
"Submit", "Job", "Time", "Host", "Ok?", "Package", "Version", "Distro", "Type",
]);
let mut conn = conn_cfg.establish_connection()?;
let older_than_filter = get_date_filter("older_than", matches)?;
Expand All @@ -502,6 +502,7 @@ fn jobs(
.inner_join(schema::endpoints::table)
.inner_join(schema::packages::table)
.inner_join(schema::images::table)
.left_outer_join(schema::artifacts::table)
.into_boxed();

if let Some(submit_uuid) = matches.get_one::<uuid::Uuid>("submit_uuid") {
Expand Down Expand Up @@ -574,14 +575,25 @@ fn jobs(
models::Endpoint,
models::Package,
models::Image,
Option<models::Artifact>,
)>(&mut conn)?
.into_iter()
.rev() // required for the --limit implementation
.map(|(job, submit, ep, package, image)| {
.map(|(job, submit, ep, package, image, artifact)| {
let success = is_job_successfull(&job)?
.map(|b| if b { "yes" } else { "no" })
.map(String::from)
.unwrap_or_else(|| String::from("?"));
let artifact_type = if let Some(artifact) = artifact {
artifact
.path
.split(".")
.last()
.map(str::to_uppercase)
.unwrap_or(String::from("?"))
} else {
String::from("-")
};

Ok(vec![
submit.uuid.to_string(),
Expand All @@ -592,6 +604,7 @@ fn jobs(
package.name,
package.version,
image_name_lookup.shorten(&image.name),
artifact_type,
])
})
.collect::<Result<Vec<_>>>()?;
Expand Down

0 comments on commit e446e2f

Please sign in to comment.