Skip to content
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

Bug: Archive in InitialWorkDirRequirement error with cwltool #69

Closed
aleidel opened this issue Feb 4, 2025 · 4 comments
Closed

Bug: Archive in InitialWorkDirRequirement error with cwltool #69

aleidel opened this issue Feb 4, 2025 · 4 comments
Assignees
Labels
bug Something isn't working Client

Comments

@aleidel
Copy link
Contributor

aleidel commented Feb 4, 2025

There is a bug in for fixed inputs when dealing with archived data (e.g. RData files). Currently s4n tool create -i preprocessed.RData -i metadata.RData -o reshaped.RData Rscript workflows/reshape_data/reshape_data.R would create the following cwl file:

#!/usr/bin/env cwl-runner

cwlVersion: v1.2
class: CommandLineTool

requirements:
- class: InitialWorkDirRequirement
  listing:
  - entryname: preprocessed.RData
    entry:
      $include: ../../preprocessed.RData
  - entryname: metadata.RData
    entry:
      $include: ../../metadata.RData
  - entryname: reshape_data.R
    entry:
      $include: reshape_data.R

inputs: []
outputs:
- id: reshaped
  type: File
  outputBinding:
    glob: reshaped.RData

baseCommand:
- Rscript
- reshape_data.R

s4n execution is successful but cwltool execution is not working
cwltool workflows/reshape_data/reshape_data.cwl due to RData file.
error:

ERROR I'm sorry, I couldn't load this CWL file, try again with --debug for more information.
The error was: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte`

s4n execute local workflows/reshape_data/reshape_data.cwl does work.

It would be possible to have a cwl file and a yaml file (or call with arguments) that looks like this:

#!/usr/bin/env cwl-runner

cwlVersion: v1.2
class: CommandLineTool

requirements:
- class: InitialWorkDirRequirement
  listing:
  - entryname: preprocessed.RData
    entry: $(inputs.preprocessed_RData)
  - entryname: metadata.RData
    entry: $(inputs.metadata_RData)
  - entryname: reshape_data.R
    entry:
      $include: reshape_data.R

inputs:
- id: preprocessed_RData
  type: File
- id: metadata_RData
  type: File

outputs:
- id: reshaped
  type: File
  outputBinding:
    glob: reshaped.RData

baseCommand:
- Rscript
- reshape_data.R

This would allow execution with cwltool or with s4n execute local --runner cwltool workflows/reshape_data.cwl --preprocessed_RData preprocessed.RData --metadata_RData metadata.RData or s4n execute local --runner cwltool workflows/reshape_data/reshape_data.cwl workflows/reshape_data/reshape_data_inputs.yml but not without --runner cwltool (or maybe I did something wrong)
s4n execute local workflows/reshape_data/reshape_data.cwl --preprocessed_RData preprocessed.RData --metadata_RData metadata.RData

📁 Created staging directory: "/tmp/.tmpXz3xVr"
thread 'main' panicked at src/io.rs:162:62:
Could not read file ./preprocessed.RData
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@aleidel aleidel added bug Something isn't working Client labels Feb 4, 2025
@aleidel
Copy link
Contributor Author

aleidel commented Feb 4, 2025

Could change cwl file creation to 2. version (above) if one of the inputs is an archive and create a yml file with the parameters. Then user would need to have cwltool installed to run it???

@JensKrumsieck
Copy link
Collaborator

$include appends the text to the cwl file and does not work with binaries. So V2 would be more correct.
s4n execute local is something we have control of, so it could be fixed at a later point

@aleidel
Copy link
Contributor Author

aleidel commented Feb 4, 2025

Okay, I will change it

@aleidel aleidel self-assigned this Feb 4, 2025
@aleidel aleidel closed this as completed Feb 11, 2025
@hvwaldow hvwaldow reopened this Feb 11, 2025
@JensKrumsieck
Copy link
Collaborator

JensKrumsieck commented Feb 12, 2025

What is the reason for the execute_cwl_local-fn? And why does it say CWLTool is needed? We can not use cwltool in s4n tool create!! Furthermore everythin in tool create happens in the users local folder.

fn execute_cwl_local(
mut cwl: CommandLineTool,
args: &CreateToolArgs,
repo: &Repository,
inputs: &[String],
) -> Result<CommandLineTool, Box<dyn std::error::Error>> {
if args.is_raw {
warn!("Temporary files are created for local execution");
}
let path = get_qualified_filename(&cwl.base_command, args.name.clone());
let mut yaml_cwl = cwl.save(&path);
yaml_cwl = format_cwl(&yaml_cwl)?;
std::fs::write(&path, yaml_cwl.as_bytes())?;
warn!("Execution requires CWLTool");
let input_refs: Vec<&str> = inputs.iter().map(|s| s.as_str()).collect();
let yaml = create_input_yml(&input_refs, &path)?;
let yaml_str = path.replace(".cwl", "_inputs.yml");
if !args.no_commit && !args.is_raw {
stage_file(repo, path.as_str())?;
stage_file(repo, &yaml_str)?;
commit(repo, &format!("Execution of `{}`", args.command.join(" ")))?;
}
// Execute locally
let args_exec = LocalExecuteArgs {
runner: Runner::CWLTool,
out_dir: None,
is_quiet: false,
file: PathBuf::from(&path),
args: vec![yaml.clone()],
};
execute_local(&args_exec)?;
if args.is_raw {
fs::remove_file(yaml)?;
fs::remove_file(&path)?;
}
Ok(cwl)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Client
Projects
None yet
Development

No branches or pull requests

3 participants