wdl-cwl-translator
wdl-cwl-translator copied to clipboard
Try a different module/package structure
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
Codecov Report
Merging #151 (240439e) into main (0db1555) will increase coverage by
0.22%. The diff coverage is95.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 dataPowered by Codecov. Last update 0db1555...240439e. Read the comment docs.
I suspect the coverage change is due to changes in line numbers.
Happy to keep rebasing/fixing conflicts so we can get @Th3nn3ss 's & @mr-c 's PRs in first :wave:
Will update this PR over the next days :muscle:
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.
Done!