-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script documenting how the 'job_info' example output was genera…
…ted (including the anonymization of username and job name)
- Loading branch information
1 parent
3a37a8f
commit aa67669
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,29 @@ | ||
library(here) | ||
library(dplyr) | ||
library(stringr) | ||
source(here('R', 'job_info.R')) | ||
|
||
# Randomly grab 100 jobs running now on the 'shared' partition | ||
job_df = job_info(user = NULL) |> | ||
sample_n(size = 100) |> | ||
arrange(job_id) | ||
|
||
# A vector whose values are anonymous usernames and whose names are the | ||
# original usernames | ||
user_map = paste0('user', 1:length(unique(job_df$user))) | ||
names(user_map) = unique(job_df$user) | ||
|
||
# Similarly for job names, though we'll keep the generic name for interactive | ||
# jobs ('bash') | ||
name_map = paste0('my_job_', 1:length(unique(job_df$name))) | ||
names(name_map) = unique(job_df$name) | ||
name_map['bash'] = 'bash' | ||
|
||
# Anonymize username and job name | ||
job_df = job_df |> | ||
mutate( | ||
user = user_map[user], | ||
name = name_map[name] | ||
) | ||
|
||
saveRDS(job_df, here('inst', 'extdata', 'job_info_df.rds')) |