IUC want profile in the <tool> and detect_errors in the <command>#38
IUC want profile in the <tool> and detect_errors in the <command>#38hexylena merged 21 commits intohexylena:masterfrom
Conversation
Only way I could get it to work was to make command an XMLParam and add the command string as an etree.CDATA. It passes tests including a new one for the command but I'm not sure if this is the most efficient way to achieve this goal.
bernt-matthias
left a comment
There was a problem hiding this comment.
Good idea to allow setting a tool's profile and a command's detect_errors property.
Is setting detect_errors to anything else than "aggressive" supported?
Can you add a test showing how to set non-default values?
edit: you meant in the python side. Yes, would like a test for that. (And a diffrent default) |
|
@bernt-matthias where are you with #37, should we merge it? I'd like the github workflow that you've done there. |
Ready for review... Not sure if tests succeed yet. Can also separate the workflow in a separate PR if needed. |
|
Thanks @hexylena and @bernt-matthias! Yes, defaults are both what @bgruening asked for in bgruening/galaxytools#1326. AFAIK, those should properly be determined by the IUC I think, not me - I'm just doing what I was asked and will be happy to meet their requirements. and They should both be explicitly set by the caller, like this example from the ToolFactory for profile: and here for detect_errors: These changes already have one new unit test and import_xml_sample has these elements - and they appear to be correctly parsed and set in the unit test. The ToolFactory tests them too if I use this updated galaxyxml and it passes its own tests. The defaults are the settings suggested. Perhaps too conservative and obviously the caller has the power to set them as they wish. Happy to change them if someone who is better placed to advise than Bjoern is willing to make a ruling?. |
That old problem of the galaxy utility libs being stuck at 23.05 is biting.
I wonder when they will be updated and all the downstream packages?
` File "/home/ross/rossgit/galaxyxml/.venv/lib/python3.10/site-packages/galaxy_tool_util-23.0.5-py3.10.egg/galaxy/tool_util/deps/conda_util.py", line 90, in CondaContext
_conda_version: Optional[Union[packaging.version.Version, packaging.version.LegacyVersion]]
AttributeError: module 'packaging.version' has no attribute 'LegacyVersion'
`
|
@hexylena @bernt-matthias Is anything not yet being tested that needs testing for these changes to be acceptable? |
…t error user set values
|
I guess the most undebatable option is to use Galaxy's defaults, ie to not set them by default. Btw would this be done by setting the value to But I'm fine with any default. |
|
Thanks @bernt-matthias - So all good? |
|
For your PRs I would suggest to go with marius' suggestion bgruening/galaxytools#1326 (comment), ie set |
|
ok. one moment please.... |
|
I don't see in your coffee the possibility to omit the two attributes from the generated xml |
seems just fine.
|
ok Thanks again @bernt-matthias. |
Thanks again, @bernt-matthias but if you remove profile from the sample, it parses without a problem, and detect errors is also not there or in the output - so missing in the input is harmless. However, the emitted xml has what was supplied or the default profile if there was not one, satisfying https://galaxy-iuc-standards.readthedocs.io/en/latest/best_practices/tool_xml.html?highlight=profile#tool-profile and the rule that one should be forgiving of what is ingested but strict in what is emitted. Are there situations where that guideline should not be followed in generating XML? If we are not following those guidelines, it's going to be hard to make a good decision. |
|
@hexylena @bernt-matthias: please let me know what outstanding issues remain that block this from being merged? |
This library isn't intended to generate IUC best practice tools, that's not it's goal, it's intended to let you flexibly generate the tool you need.
this is a prescriptivist take (these are our rules and they are the only right way) and this library is targetted at people that know what they want to do and want flexibility, not enforcing IUC best practices (as you'll note, it's not under galaxy-iuc) |
bernt-matthias
left a comment
There was a problem hiding this comment.
I think there are now some diffs in the example:
python examples/example.py > tmp.xml
xmldiff tmp.xml examples/tool.xml
python examples/example_macros.py > tmp.xml
xmldiff tmp.xml examples/example_macros.xml
Can you fix those?
test/unit_test_import_xml.py
Outdated
| try: | ||
| de = self.tool.command.node.attrib["detect_errors"] | ||
| except KeyError: | ||
| de = None |
There was a problem hiding this comment.
Fix indentation here.
test/unit_test_import_xml.py
Outdated
| self.tool.command.node.attrib["detect_errors"] = "foobarfoo" | ||
| de = self.tool.command.node.attrib["detect_errors"] | ||
| self.assertEqual(de, "foobarfoo") |
There was a problem hiding this comment.
I don't understand this test. Looks like:
A = "foobarfoo"
B = A
self.assertEqual(B, "foobarfoo")
Same for the following two lines.
There was a problem hiding this comment.
yes. Makes sure they are persistent and mutable after the previous test checks the correct values have been extracted from the sample. Was trying to respond to a previous suggestion. Will remove it.
| @@ -1,5 +1,5 @@ | |||
| <?xml version="1.0"?> | |||
| <tool id="import_test" name="Import" version="1.0"> | |||
There was a problem hiding this comment.
The xml examplifies the defaults, or?
|
@bernt-matthias you have most of the same review comments I did 😅 I should've hit submit earlier |
hexylena
left a comment
There was a problem hiding this comment.
As of now it doesn't pass the tests (the other tests, in the .travis.yml that we didn't finish turning into a GHA.). I will update those @fubar2 .
$ diff tmp.xml examples/tool.xml
1c1
< <tool name="aragorn" id="se.lu.mbioekol.mbio-serv2.aragorn" version="1.2.36" profile="22.05">
---
> <tool name="aragorn" id="se.lu.mbioekol.mbio-serv2.aragorn" version="1.2.36">
7a8,11
> <stdio>
> <exit_code range="1:" level="fatal"/>
> </stdio>
> <expand macro="stdio"/>
9,10c13
< <command><![CDATA[
< aragorn.exe $flag
---
> <command><![CDATA[aragorn.exe $flagand yeah, fine with dropping the stdio, but still not crazy about adding profile by default, that really seems like something for library consumers to do. I also don't understand the newline being added there.
galaxyxml/tool/__init__.py
Outdated
| command_line = self.command_override | ||
| command_text = self.command_override |
There was a problem hiding this comment.
Plan to revert all this - part of the command attributes change.
Took me a while to get my head around where the actual command text was being found in the new XMLParam and I discovered I was reusing a variable name. Went the wrong way - sorry - should have backed out but forged ahead with new names. Will soon be back to what it was.
There was a problem hiding this comment.
The stdio default insertion is dropped.
Stdios still work fine if you want to use them. :)
This all started when I was asked to add profile and remove that deprecated default stdio value, in a review of some tools generated using galaxyxml, so not sure what else I can do here.
galaxyxml/tool/import_xml.py
Outdated
| <command> is already loaded during initiation. | ||
|
|
||
| :param tool: Tool object from galaxyxml. | ||
| :type tool: :class:`galaxyxml.tool.Tool` | ||
| :param desc_root: root of <command> tag. | ||
| :type desc_root: :class:`xml.etree._Element` | ||
| now an XMLParameter with a text |
There was a problem hiding this comment.
please don't delete documentation, update it if it needs updating.
| # Steal interpreter from kwargs | ||
| command_kwargs = {} | ||
| if export_xml.interpreter is not None: | ||
| command_kwargs["interpreter"] = export_xml.interpreter |
There was a problem hiding this comment.
yes, ok, this should not have been included. good. https://docs.galaxyproject.org/en/latest/dev/schema.html#id22 @bernt-matthias the documentation looks a bit odd there.
galaxyxml/tool/__init__.py
Outdated
| if getattr(self, "command_line", None): | ||
| ctext = export_xml.command_text |
There was a problem hiding this comment.
now that you've renamed command_line, this should be command_text, right?
| if getattr(self, "command_line", None): | |
| ctext = export_xml.command_text | |
| if getattr(self, "command_text", None): | |
| ctext = export_xml.command_text |
galaxyxml/tool/__init__.py
Outdated
| ) | ||
| ctext = actual_cli.strip() | ||
| export_xml.command_text = ctext | ||
| ctext = '\n' + ctext # pretty - bjoern's suggestion |
There was a problem hiding this comment.
I don't love this tbh, it'll introduce lots of diffs to add some useless whitespace. If you want a newline in your command add it, if you want it pretty, run it through planemo. This isn't the job of this library
tox.ini
Outdated
| [testenv] | ||
| description = run the tests with pytest | ||
| package = wheel | ||
| wheel_build_env = .pkg | ||
| deps = | ||
| pytest>=6 | ||
| commands = | ||
| pytest test/unit_test_import_xml.py {tty:--color=yes} {posargs} |
There was a problem hiding this comment.
We have not been using tox to test, this is a bigger change, hmm. until now it was all nose, which apparently is now broken. I really wish some of these changes had come in separate PRs so we could've discussed them in isolation, but I guess we have to accept this because nose is non functional.
|
I would recommand also that don't make PRs from your |
I fixed the first set, I'm still struggling to figure out why the second set changed, @fubar2 maybe you can fix that. |
|
ok - thanks for the comments - appreciated. Most problems are from changes to make Apologies for the import sample changes - from using it to confirm that either missing or supplied values were handled - shouldn't have committed those. |
|
It happens, no worries. Let's not dwell.
|
|
ok. |
Apologies - my immediate problem is to get things past review elsewhere - sorry it spilled over where it does not belong. I'll advocate for the changed defaults recommended by those reviewers, but all those decisions are entirely yours... |
|
I hope all the worst is gone and it's ready for another review. |
It would be great to get it updated but, things move very very slowly there it seems. c.f. my indentation PR allowing tabs, which is now dormant since months. We also didn't have the 'traditional' IUC meeting at GCC too, so, didn't have the usual going through of issues/etc. |
…ds to start with test for tox to run automagically it seems. Reverted the sample
|
github action flake now unhappy so format issues to resolve or silence? |
|
Feel free to ignore flake. I've pushed a commit to take care of one test, then there's only one more failure: Previously the outmacro had included an So I will merge over this specific failure, and maybe if you have energy and bandwidth, if you have a nice fix for it, i think it would be useful to the library's consumers to retain this todo/-output flake rantIt's stuff black will take care of which is especially, especially frustrating for me. Why lint and make a human fix it, just fix it and shut up (I say to flake/black.) These ridiculous tools should either fix it automatically because it's bloody whitespace, or stop complaining. `isort` is banned from all of my projects because it drives me up a wall. |
|
Thanks for the patience @fubar2 and putting up with our complaints. I'll mint a new release for ya |
|
after a silly amoutn of fighting with pypi/gha, https://pypi.org/project/galaxyxml/0.5.3/ now exists. |
Hi @hexylena!
Request from the IUC to add boilerplate doodads to ToolFactory outputs, so this PR elevates command to an XMLParam, adding the command string as a CDATA text. It passes tests including the new one and more importantly, the existing one, though I'm not sure if this is the most efficient path. Whatever, it works for me FWIW - thanks!