danforthcenter / plantcv

Plant phenotyping with image analysis
Mozilla Public License 2.0
652 stars 263 forks source link

Error:aguments are required: --image during Workflow Parallelization work #1513

Closed LisaLiu11 closed 2 months ago

LisaLiu11 commented 5 months ago

Describe the bug Hi all, when I try to use the Parallel workflow for all my pictures running on a terminal, the latest error I got is as follows. usage: FFinal-plantcv-workflow.py [-h] --image IMAGE --result RESULT --outdir OUTDIR [--writeimg] [--debug DEBUG] Final-plantcv-workflow.py: error: the following arguments are required: --image

I get confusion how it works with my script as I'm not a computer expert. As plantcv updates a lot, i havent found any the latest full article or video to learn how Parallel workflow works. I'm using the instructions from plantcv website and also the workshop video (https://www.youtube.com/watch?v=zvn_05cE0L4&t=6225s) and also the latest publication (https://github.com/HausMJ/RootDS_PythonCode/blob/main/Logan_Root_Colorizer_Workflow_v1.2.py) to learn myself how it works. Unfortunately, it is not working for many days. I'm wondering if there is any clear full instruction released to teach non-expert how this Parallel workflow works? Could anyone please share any suggestions for this issue? I sincerely appreciate your help in advance.

part of my code for input.py based on old instruction is : def options(): """Parse command-line options

The options function was converted from the class options in Jupyter.
Rather than hardcoding the inputs, input arguments with the same
variable names are used to retrieve inputs from the commandline.

"""
parser = argparse.ArgumentParser(description="PlantCV plant workflow")
parser.add_argument("--image", help="Input image", required=True)
parser.add_argument("--result", help="Results file", required=True)
parser.add_argument("--outdir", help="Output directory", required=True)
parser.add_argument("--writeimg", help="Save output images", action="store_true")
parser.add_argument("--debug", help="Set debug mode", default=None)
args = parser.parse_args()
return args

Local environment (please complete the following information):

HaleySchuhl commented 5 months ago

Hi @LisaLiu11 thanks for opening this issue and providing a good amount of detail, this is very helpful. I noticed that you say you're on v4.0, which means the youtube tutorial is outdated. In version 4 we have transition to a configuration file based parallelization, with aims of being more user friendly and increase reproducibility. We have an example documented here. Hopefully this can resolve your parallelization error, but please do not hesitate to follow up with further questions.

EDIT: It's maybe also worth mentioning there have been a few bug fixes that have merged since our 4.0 release, so I'd recommend updating your plantcv version in your conda environment to 4.2.1 👍

LisaLiu11 commented 5 months ago

Hi Haley, thank you very much for the guidance. I tried to work again with the latest instruction on the website, I changed my workflow python file into:

Get command-line options

args = workflow_inputs() pcv.params.debug = args.debug
img, imgpath, imgname = pcv.readimage(filename=args.image)

then run the run plantcv-run-workflow with a config on the terminal, then i got this error:

img, imgpath, imgname = pcv.readimage(filename=args.image)
                                               ^^^^^^^^^^

AttributeError: 'Namespace' object has no attribute 'image'. Did you mean: 'images'?

I tried to change it into (filename=args.images), but it is still not working. Could I ask some suggestion for this situation? sorry for many questions as im really not familar with this part!

HaleySchuhl commented 5 months ago

Admittedly, this is one of the more confusing parts of our current parallelization structure, and we are working to make more complete tutorials hosted with Scribe. This attribute error is one that others have gotten stuck on too, so we talked this morning on ways to improve in v5, but for the time being...

If you change group_name = “auto” in your config file, then it will automatically name your image argument as args.image1. Making these two updates should hopefully resolve that error.