Skip to content

Commit

Permalink
add workflow-monitor-path parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
nebfield committed Sep 18, 2023
1 parent 84ff216 commit 0fc7f10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion data/templates/callback.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -euxo pipefail
module load python-data/3.10-23.07

# run the monitor in the background
python3 {workflow_monitor_path} \
{workflow_monitor_path} \
--callback_token $CALLBACK_TOKEN \
--namespace {namespace} &

Expand Down
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ struct Args {
globus_jar_path: PathBuf,
/// Which platform namespace do you want to deploy to? [dev, test, prod]
#[arg(short, long, value_enum)]
namespace: PlatformNamespace
namespace: PlatformNamespace,
/// Path to the workflow monitor binary (installed in a venv)
#[arg(long)]
workflow_monitor_path: PathBuf,
}

/// A directory for storing working data
Expand Down Expand Up @@ -105,7 +108,7 @@ async fn main() {

if let Some(jobs) = jobs {
for job in jobs {
let job_path = job.create(&wd, &args.globus_jar_path, &args.namespace);
let job_path = job.create(&wd, &args.globus_jar_path, &args.namespace, &args.workflow_monitor_path);
if !args.dry_run {
job.stage(&conn);
job.submit(&conn, job_path);
Expand Down
10 changes: 5 additions & 5 deletions src/slurm/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ pub struct JobPath {
}

impl JobRequest {
pub fn create(&self, wd: &WorkingDirectory, globus_path: &PathBuf, namespace: &PlatformNamespace) -> JobPath {
pub fn create(&self, wd: &WorkingDirectory, globus_path: &PathBuf, namespace: &PlatformNamespace,
monitor_path: &PathBuf) -> JobPath {
let instance_wd = WorkingDirectory { path: wd.path.join(&&self.pipeline_param.id) };
info!("Creating job {} in working directory {}", &&self.pipeline_param.id, &instance_wd.path.display());

Expand All @@ -35,7 +36,7 @@ impl JobRequest {
fs::create_dir(&instance_wd.path).expect("Create working directory");

let header: Header = render_header(&&self.pipeline_param);
let callback: Callback = render_callback(&&self.pipeline_param, &namespace);
let callback: Callback = render_callback(&&self.pipeline_param, &namespace, &monitor_path);
let vars: EnvVars = read_environment_variables();
let workflow: Workflow = render_nxf(&globus_path, &&self.pipeline_param, &wd.path, &namespace);
let job = JobTemplate { header, callback, vars, workflow };
Expand Down Expand Up @@ -234,15 +235,14 @@ fn render_nxf(globus_path: &PathBuf, param: &PipelineParam, work_dir: &Path, nam
}

/// Render the callback using TinyTemplate
fn render_callback(param: &PipelineParam, namespace: &PlatformNamespace) -> Callback {
fn render_callback(param: &PipelineParam, namespace: &PlatformNamespace, monitor_path: &&PathBuf) -> Callback {
/// included callback template
static CALLBACK: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/templates/callback.txt"));
let mut tt = TinyTemplate::new();
tt.add_template("callback", CALLBACK).expect("Template");
let name: &String = &param.id;
static WORKFLOW_MONITOR_PATH: &str = "/scratch/project_2004504/bwingfield/workflow-monitor/main.py";
let context = CallbackContext { name: name.clone(),
workflow_monitor_path: WORKFLOW_MONITOR_PATH.to_string(),
workflow_monitor_path: monitor_path.to_string_lossy().to_string(),
namespace: namespace.to_string()
};
Callback { content: tt.render("callback", &context).expect("Rendered callback") }
Expand Down

0 comments on commit 0fc7f10

Please sign in to comment.