jennahamlin / mashwrapper

MIT License
5 stars 1 forks source link

add python3 version check #4

Closed chrisgulvik closed 2 years ago

chrisgulvik commented 2 years ago

Description of feature

It might be nice to add a python version check just to verify it's some py3 version. Something like python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))' prints just 2.7.5 for me.

A modern env will probably have py3 as default but in a system I tested that had py2.7, it ran through trying to use it which failed due to newer syntax used that requires py3.

Example Commands:

  1. local download the workflow to $HOME git clone https://github.com/jennahamlin/mashwrapper.git $HOME/mashwrapper

  2. make nextflow available on HPC module purge && ml nextflow

  3. view versions

    % python --version 2>&1 | sed 's/Python //1'
    2.7.5
    % nextflow -version 2>&1 | grep "      version " | awk '{print $2}'
    22.04.3
  4. test run db download nextflow run $HOME/mashwrapper/main.nf -profile testGet

Example Error (due to py2 being used instead of py3):

N E X T F L O W  ~  version 22.04.3
Launching `$HOME/mashwrapper/main.nf` [stoic_shirley] DSL2 - revision: 06b0d4506b

WARN: Found unexpected parameters:
* --genome: R64-1-1
- Ignore this warning: params.schema_ignore_params = "genome"

------------------------------------------------------
                                        ,--./,-.
        ___     __   __   __   ___     /,-._.--~'
  |\ | |__  __ /  ` /  \ |__) |__         }  {
  | \| |       \__, \__/ |  \ |___     \`-._,-`-,
                                        `._,._,'
  jennahamlin/mashwrapper v1.0dev
------------------------------------------------------
Core Nextflow options
  runName                   : stoic_shirley
  launchDir                 : $HOME
  workDir                   : $HOME/work
  projectDir                : $HOME/mashwrapper
  userName                  : ylo1
  profile                   : testGet
  configFiles               : $HOME/mashwrapper/nextflow.config

Input/output options
  input                     : https://raw.githubusercontent.com/jennahamlin/mashwrapper/main/test-data/inputReads.csv

Database options
  get_database              : https://raw.githubusercontent.com/jennahamlin/mashwrapper/main/test-data/inputDB.txt

Institutional config options
  config_profile_name       : Test profile
  config_profile_description: Minimal test dataset to check pipeline function

Max job request options
  max_cpus                  : 2
  max_memory                : 6.GB
  max_time                  : 6.h

!! Only displaying parameters that differ from the pipeline defaults !!
------------------------------------------------------
If you use jennahamlin/mashwrapper for your analysis please cite:

* The nf-core framework
  https://doi.org/10.1038/s41587-020-0439-x

* Software dependencies
  https://github.com/jennahamlin/mashwrapper/blob/master/CITATIONS.md
------------------------------------------------------
[cf/4048f9] Submitted process > NFCORE_MASHWRAPPER:MASHWRAPPER:ORGANISMSHEET_CHECK (inputDB.txt)
[30/cb5389] Submitted process > NFCORE_MASHWRAPPER:MASHWRAPPER:INPUT_CHECK:SAMPLESHEET_CHECK (inputReads.csv)
Error executing process > 'NFCORE_MASHWRAPPER:MASHWRAPPER:ORGANISMSHEET_CHECK (inputDB.txt)'

Caused by:
  Process `NFCORE_MASHWRAPPER:MASHWRAPPER:ORGANISMSHEET_CHECK (inputDB.txt)` terminated with an error exit status (1)

Command executed:

  check_organismsheet.py \
      "inputDB.txt"\
      organismsheet_valid.txt \

  cat <<-END_VERSIONS > versions.yml
  "NFCORE_MASHWRAPPER:MASHWRAPPER:ORGANISMSHEET_CHECK":
      python: $(python --version | sed 's/Python //g')
  END_VERSIONS

Command exit status:
  1

Command output:
  (empty)

Command error:
    File "$HOME/mashwrapper/bin/check_organismsheet.py", line 47
      def head_file(filename: str, n: int):
                            ^
  SyntaxError: invalid syntax

Work dir:
  $HOME/work/cf/4048f9de6376527a6e8fc609cc887e

Tip: when you have fixed the problem you can continue the execution adding the option `-resume` to the run command line

Execution cancelled -- Finishing pending tasks before exit
-[jennahamlin/mashwrapper] Pipeline completed with errors-
WARN: To render the execution DAG in the required format it is required to install Graphviz -- See http://www.graphviz.org for more info.
chrisgulvik commented 2 years ago

adding "docker" or "singularity" in the profile opt does pull in py3 as expected, so feature would only help users that don't specify either of those

jennahamlin commented 2 years ago

Added check for python3 rather than python2: See https://github.com/jennahamlin/mashwrapper/commit/0fce171f6c1aa44b6d40d4c0c42924f51436b197