Install python modules when running cwl

Hello everyone,

So I am new to CWL and I am trying to implement my very first workflow to call some python scripts.

So far I’ve done some tests with basic python scripts and got them working, but when I want to use my real python scripts I encounter some issues regarding the import of certain python modules, i.e: “ModuleNotFoundError”. The modules are installed on my system and I can import them outside the CWL environment, so I guess I get the error because the module does not exist in the CWL container? How could I solve this issue?

Is there a way to install all the necessary modules at the begining of the workflow? The python modules that I need to import are used by several python scripts that will be called at different steps of the workflow.

Here are my CWL codes: the main one that calls the others for each step (so far I have just one step), and the one that calls the python script.

Thanks in advance!

#!/usr/bin/env cwl-runner
cwlVersion: v1.0
class: Workflow


inputs:
  zipFile: string
  
outputs:
  b1:
    type: Directory
    outputSource: unzip_files/b1
  t1:
    type: Directory
    outputSource: unzip_files/t1
  t2_am:
    type: Directory
    outputSource: unzip_files/t2_am
  t2_ph:
    type: Directory
    outputSource: unzip_files/t2_ph
  segmentation:
    type: Directory
    outputSource: unzip_files/segmentation
    
    
steps:    
  unzip_files:
    run: unzip.cwl
    in:
      zipFileIn: zipFile
    out: [b1, t1, t2_am, t2_ph, segmentation]
     

cwlVersion: v1.0
class: CommandLineTool

baseCommand: python

inputs:
  outPutDir: 
    type: string
    default: $(runtime.outdir)
    inputBinding:
      position: 3

  zipFileIn: 
    type: string
    inputBinding:
      position: 2

  script:
    type: File
    inputBinding:
      position: 1
    default:
      class: File
      location: ./QSM_pipeline/01_unzip.py
  

outputs:
  b1:
    type: Directory
    outputBinding:
      glob: "01-b1"
  t1:
    type: Directory
    outputBinding:
      glob: 02-t1"
  t2_am:
    type: Directory
    outputBinding:
      glob: "03-t2"
  t2_ph:
    type: Directory
    outputBinding:
      glob: "04-t2"
  segmentation:
    type: Directory
    outputBinding:
      glob: "05-segmentation"