Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.

Commit 01bcf41

Browse files
committed
wip: squash back in in-situ branch changes
1 parent a9958bf commit 01bcf41

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

wdl-engine/src/backend/lsf_apptainer.rs

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use crate::STDERR_FILE_NAME;
2626
use crate::STDOUT_FILE_NAME;
2727
use crate::TaskExecutionResult;
2828
use crate::config::Config;
29-
use crate::config::TaskResourceLimitBehavior;
3029
use crate::path::EvaluationPath;
3130
use crate::v1;
3231

@@ -132,6 +131,28 @@ impl TaskManagerRequest for LsfApptainerTaskRequest {
132131
//
133132
// TODO ACF 2025-09-10: make the persistence of the tempdir configurable
134133
let container_temp_dir = TempDir::new_in(self.spawn_request.attempt_dir())?;
134+
let container_tmp_path = container_temp_dir.path().join("tmp").to_path_buf();
135+
tokio::fs::DirBuilder::new()
136+
.recursive(true)
137+
.create(&container_tmp_path)
138+
.await
139+
.with_context(|| {
140+
format!(
141+
"failed to create container /tmp directory at `{path}`",
142+
path = container_tmp_path.display()
143+
)
144+
})?;
145+
let container_var_tmp_path = container_temp_dir.path().join("var_tmp").to_path_buf();
146+
tokio::fs::DirBuilder::new()
147+
.recursive(true)
148+
.create(&container_var_tmp_path)
149+
.await
150+
.with_context(|| {
151+
format!(
152+
"failed to create container /var/tmp directory at `{path}`",
153+
path = container_var_tmp_path.display()
154+
)
155+
})?;
135156

136157
// Assemble the Apptainer invocation. We'll write out this command to the host
137158
// filesystem, and ultimately submit it as the command to run via LSF.
@@ -196,12 +217,12 @@ impl TaskManagerRequest for LsfApptainerTaskRequest {
196217
write!(
197218
&mut apptainer_command,
198219
"--mount type=bind,src={},dst=/tmp ",
199-
container_temp_dir.path().join("tmp").display()
220+
container_tmp_path.display()
200221
)?;
201222
write!(
202223
&mut apptainer_command,
203224
"--mount type=bind,src={},dst=/var/tmp ",
204-
container_temp_dir.path().join("var_tmp").display()
225+
container_var_tmp_path.display()
205226
)?;
206227
write!(
207228
&mut apptainer_command,
@@ -233,6 +254,7 @@ impl TaskManagerRequest for LsfApptainerTaskRequest {
233254
apptainer_command_path.display()
234255
)
235256
})?;
257+
fs::set_permissions(&apptainer_command_path, Permissions::from_mode(0o777)).await?;
236258

237259
// The path for the LSF-level stdout and stderr. This primarily contains the job
238260
// report, as we redirect Apptainer and WDL output separately.
@@ -324,6 +346,9 @@ impl TaskManagerRequest for LsfApptainerTaskRequest {
324346
// the containerized command has completed.
325347
let bsub_result = bsub_child.wait().await?;
326348

349+
// Hang onto the container tmp dir until execution is complete.
350+
drop(container_temp_dir);
351+
327352
Ok(TaskExecutionResult {
328353
// Under normal circumstances, the exit code of `bsub -K` is the exit code of its
329354
// command, and the exit code of `apptainer exec` is likewise the exit code of its
@@ -432,7 +457,20 @@ impl TaskExecutionBackend for LsfApptainerBackend {
432457
// TODO ACF 2025-09-11: set a hard memory limit with `bsub -M !`?
433458
let _max_memory = v1::max_memory(hints)?.map(|i| i as u64);
434459

435-
let name = request.id()[0..LSF_JOB_NAME_MAX_LENGTH].to_string();
460+
// Truncate the request ID to fit in the LSF job name length limit.
461+
//
462+
// TODO ACF 2025-09-12: test to see whether LSF even accepts non-ascii job
463+
// names...
464+
let request_id = request.id();
465+
let name = if request_id.len() > LSF_JOB_NAME_MAX_LENGTH {
466+
request_id
467+
.chars()
468+
.take(LSF_JOB_NAME_MAX_LENGTH)
469+
.collect::<String>()
470+
} else {
471+
request_id.to_string()
472+
};
473+
436474
self.manager.send(
437475
LsfApptainerTaskRequest {
438476
engine_config: self.engine_config.clone(),
@@ -471,7 +509,7 @@ impl TaskExecutionBackend for LsfApptainerBackend {
471509
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
472510
pub struct LsfApptainerBackendConfig {
473511
// TODO ACF 2025-09-12: add queue option for short tasks
474-
queue: Option<String>,
512+
pub queue: Option<String>,
475513
}
476514

477515
impl LsfApptainerBackendConfig {

wdl-engine/tests/tasks.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use regex::Regex;
3535
use serde_json::to_string_pretty;
3636
use tempfile::TempDir;
3737
use tokio_util::sync::CancellationToken;
38+
use tracing::info;
3839
use walkdir::WalkDir;
3940
use wdl_analysis::Analyzer;
4041
use wdl_ast::Diagnostic;
@@ -298,6 +299,8 @@ async fn run_test(test: &Path, config: config::Config) -> Result<()> {
298299

299300
let evaluator = TaskEvaluator::new(config, CancellationToken::new(), Events::none()).await?;
300301
let dir = TempDir::new().context("failed to create temporary directory")?;
302+
info!(dir = %dir.path().display(), "test temp dir created");
303+
301304
match evaluator
302305
.evaluate(result.document(), task, &inputs, dir.path())
303306
.await

0 commit comments

Comments
 (0)