wdl-cwl-translator icon indicating copy to clipboard operation
wdl-cwl-translator copied to clipboard

Try a different module/package structure

Open kinow opened this issue 3 years ago • 6 comments

It started over the week/holiday when I had a go at trying to write the conversion for WDL stdlib's select_all function. It didn't work for other reasons, but I noticed that the main.py keeps getting longer and longer.

So I thought we could probably reduce it a little by starting to use more modules/packages.

After reading the miniwdl code, I thought we could have a structure similar to their structure, but also thinking about CWL.

With that in mind, I thought about an wdl2cwl.expr module with the WDL Expr statements (conditionals, arithmetic, etc). And then remove the if statement from the WDL.Expr.Apply for WDL Stdlib Functions, and move that code to a separate module as well.

That resulted in wdl2cwl.functions. Furthermore, instead of using an if/elif's/else statement, we can simply check if the module has a function with the same name (coding by convention) and use it if so, otherwise raise an error as before.

While that would reduce the code, not sure if that's the best/right call for now. So happy to get any feedback. I almost finished this change, but ran out of :coffee: (head was literally bobbing while I was writing the code :sleeping: , will review in the morning :sleeping_bed: )

Cheers -Bruno

kinow avatar Feb 02 '22 12:02 kinow

Codecov Report

Merging #151 (240439e) into main (0db1555) will increase coverage by 0.22%. The diff coverage is 95.97%.

@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
+ Coverage   94.78%   95.00%   +0.22%     
==========================================
  Files           3        6       +3     
  Lines         728      761      +33     
  Branches      216      204      -12     
==========================================
+ Hits          690      723      +33     
  Misses         14       14              
  Partials       24       24              
Impacted Files Coverage Δ
wdl2cwl/expr.py 93.82% <93.82%> (ø)
wdl2cwl/functions.py 96.46% <96.46%> (ø)
wdl2cwl/errors.py 93.33% <100.00%> (+0.22%) :arrow_up:
wdl2cwl/main.py 94.60% <100.00%> (-0.22%) :arrow_down:
wdl2cwl/util.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0db1555...240439e. Read the comment docs.

codecov[bot] avatar Feb 04 '22 23:02 codecov[bot]

I suspect the coverage change is due to changes in line numbers.

kinow avatar Feb 04 '22 23:02 kinow

Happy to keep rebasing/fixing conflicts so we can get @Th3nn3ss 's & @mr-c 's PRs in first :wave:

kinow avatar Feb 04 '22 23:02 kinow

Will update this PR over the next days :muscle:

kinow avatar Mar 12 '22 01:03 kinow

Rebased, updated the code, and I think I got all the latest changes :nerd_face: :sleepy: Going to stop for now, and review it in the morning. Then try to wrap it up updating anything broken in the CI. Or, if nothing broken, then just mark it as ready for review.

kinow avatar Mar 24 '22 06:03 kinow

Done!

kinow avatar Mar 25 '22 05:03 kinow