Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autoupdate command #1065

Merged
merged 42 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
dc1b335
First Draft for autoupdate command
lorrainealisha75 Jun 23, 2020
c42db57
Putting files in the right directories
lorrainealisha75 Jun 23, 2020
dcf206a
Making minor changes
lorrainealisha75 Jun 24, 2020
81a8a83
Basic functionalityof autoupdate check-in
lorrainealisha75 Jun 25, 2020
85df40e
Minor changens in autoupdate file
lorrainealisha75 Jul 13, 2020
2b09418
modify autoupdate so that tokens can be updated correctly
simonbray Jul 29, 2020
3988282
working version of autoupdate
simonbray Jul 30, 2020
efc78ee
next commit
simonbray Aug 3, 2020
0b89771
Merge remote-tracking branch 'upstream/master' into autoupdate-sb
simonbray Aug 5, 2020
ce54d0f
next commit
simonbray Aug 6, 2020
f7dc089
minor change to logging
simonbray Aug 7, 2020
cd139a6
add conda flags
simonbray Aug 13, 2020
b572fee
linting
simonbray Aug 13, 2020
f3160e3
small changes to docs
simonbray Aug 13, 2020
b52825d
add initial draft of some documentation
simonbray Aug 13, 2020
3ba0775
some fixes
simonbray Aug 14, 2020
6536192
rewrite code
simonbray Aug 20, 2020
6b44dd8
commit
simonbray Aug 21, 2020
c5e6d5b
autoupdate
simonbray Aug 24, 2020
a1a1e3e
autoupdate
simonbray Aug 24, 2020
2cb8262
do not add +galaxy0 where not already used, requested by @wm75
simonbray Aug 24, 2020
6bd3a8a
restructure autoupdate code, small fixes
simonbray Sep 7, 2020
6185f44
add 2 test cases (w and w/o --dry-run)
simonbray Sep 7, 2020
b479570
docs linting
simonbray Sep 7, 2020
c3b4c0e
autoupdate test passing locally, try and get it to run on the CI as well
simonbray Sep 7, 2020
739f44c
[ci skip] add skiplist option as suggested by @bgruening
simonbray Sep 8, 2020
f27e282
another attempt at fixing the test
simonbray Sep 8, 2020
940b577
create xml file for autoupdate test during the test
simonbray Sep 8, 2020
f5c4711
Merge remote-tracking branch 'upstream/master' into autoupdate-sb
simonbray Sep 25, 2020
08e5988
change tests to check stdout
simonbray Sep 25, 2020
36ac709
ensure conda is installed
simonbray Sep 25, 2020
f13cce1
lint
simonbray Sep 25, 2020
c5af2af
(re)add docs
simonbray Sep 29, 2020
ed5fcc4
Merge remote-tracking branch 'upstream/master' into autoupdate-sb
simonbray Jan 5, 2021
8c1382f
do not modify os-dependent newlines when using autoupdate
simonbray Jan 14, 2021
16e6857
add skip_requirements option to autoupdate
simonbray Jan 14, 2021
5b582b5
fix bug introduced in previous commit
simonbray Mar 12, 2021
a5be98f
add link to autoupdate ci, fix update_test_data
simonbray Mar 12, 2021
bc3ed0c
add default to skip_requirements arg
simonbray Mar 13, 2021
3420eae
fix for testing
simonbray Mar 15, 2021
599cb59
fix autoupdate skip requirements, update docs, some general tidying
simonbray Mar 16, 2021
cbbbc43
update docs with @VERSION_SUFFIX@
simonbray Mar 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/autoupdate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ Planemo provides a ``autoupdate`` subcommand which can be used to perform this t
There are various flags which can be applied; these are some of the most important:
- ``--recursive``, which performs the autoupdate recursively on subdirectories
- ``--dry-run``, which checks if tool requirements are up-to-date without making the necessary change automatically
- ``--test``, which runs tests on all autoupdated tools
- ``--test``, which runs tests on all autoupdated tools. If this flag is used, all options available for ``planemo test`` are also available.
- ``--update_test_data`` (if ``--test`` is also selected) which will update test data for failed tests
- ``--skiplist``, pointing to a list of tool wrappers for which updates should be skipped
- ``--skip_requirements`` with a comma-separated list of packages not to update. ``python``, ``perl``, ``r-base`` are skipped by default.

One of the most efficient ways to use it is by implementing a CI cron job which runs the command on an entire GitHub repository of tools.
One of the most efficient ways to use it is by implementing a CI cron job which runs the command on an entire GitHub repository of tool wrappers.

Formatting tools
=============================

``autoupdate`` assumes that XML tools are formatted in a certain way - in accordance with the `IUC best practices`_

<https://planemo.readthedocs.io/en/latest/standards/docs/best_practices/tool_xml.html/>`__. In particular:
``autoupdate`` assumes that XML tools are formatted in a certain way - in accordance with the `IUC best practices`_. In particular:

- the tool ``version`` attribute must be set to ``@TOOL_VERSION@+galaxy0`` or ``@TOOL_VERSION@+galaxy@GALAXY_VERSION``
Copy link

@davelopez davelopez Mar 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- the tool ``version`` attribute must be set to ``@TOOL_VERSION@+galaxy0`` or ``@TOOL_VERSION@+galaxy@GALAXY_VERSION``
- the tool ``version`` attribute must be set to ``@TOOL_VERSION@+galaxy0`` or ``@TOOL_VERSION@+galaxy@VERSION_SUFFIX@``

;)

By the way, should this be @VERSION_SUFFIX@ instead of @GALAXY_VERSION@? The latest documentation says it should be @VERSION_SUFFIX@ but it seems a significant amount of tools use @GALAXY_VERSION@

Update: I answer myself after reading galaxy-iuc/standards#59 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right - we decided on @VERSION_SUFFIX@ in the end but I didn't update here. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's @VERSION_SUFFIX@ , @GALAXY_VERSION@ was the whole +galaxyN .

- A token ``@TOOL_VERSION@`` should be created which corresponds to the version number of the main requirement.
Expand All @@ -33,8 +33,8 @@ Formatting tools
Implementing an autoupdate CI job
=================================

A useful way to use the autoupdate command is to implement it as a CI job, so that tools in a repo can be updated on a regular basis (e.g. weekly). An example implementation is the `planemo-autoupdate`_ GitHub bot.
A useful way to use the autoupdate command is to implement it as a CI job, so that tools in a repo can be updated on a regular basis (e.g. weekly). An example implementation is the `planemo-autoupdate`_ GitHub bot.

<https://github.com/planemo-autoupdate/autoupdate/>`__

.. _IUC best practices: https://galaxy-iuc-standards.readthedocs.io/en/latest/best_practices/tool_xml.html
.. _planemo-autoupdate: https://github.com/planemo-autoupdate/autoupdate
1 change: 1 addition & 0 deletions docs/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ implemented as a subcommand of the ``planemo`` executable. This section of the
documentation describes these commands.


.. include:: commands/autoupdate.rst
.. include:: commands/ci_find_repos.rst
.. include:: commands/ci_find_tools.rst
.. include:: commands/clone.rst
Expand Down
7 changes: 6 additions & 1 deletion docs/commands/autoupdate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Auto-update tool requirements by checking against Conda and updating if newer ve
--skiplist TEXT Skiplist file, containing a list of tools for
which autoupdate should be skipped.

--skip_requirements TEXT Comma-separated list of requirements which
should be not be updated. Default is
python,r-base,perl.

--update_test_data Update test-data directory with job outputs
(normally written to directory
--job_output_files if specified.)
Expand All @@ -52,6 +56,7 @@ Auto-update tool requirements by checking against Conda and updating if newer ve
--test_output_junit PATH Output test report (jUnit style - for CI
systems

--test_output_allure DIRECTORY Output test allure2 framework resutls
--test_output_json PATH Output test report (planemo json) defaults to
tool_test_output.json.

Expand All @@ -64,7 +69,7 @@ Auto-update tool requirements by checking against Conda and updating if newer ve
--galaxy_root DIRECTORY Root of development galaxy directory to
execute command with.

--galaxy_python_version [3|3.5|3.6|3.7|3.8]
--galaxy_python_version [3|3.6|3.7|3.8|3.9]
Python version to start Galaxy under
--extra_tools PATH Extra tool sources to include in Galaxy's tool
panel (file or directory). These will not be
Expand Down
8 changes: 8 additions & 0 deletions docs/planemo.commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ planemo.commands package
Submodules
----------

planemo.commands.cmd\_autoupdate module
---------------------------------------

.. automodule:: planemo.commands.cmd_autoupdate
:members:
:undoc-members:
:show-inheritance:

planemo.commands.cmd\_ci\_find\_repos module
--------------------------------------------

Expand Down
8 changes: 8 additions & 0 deletions docs/planemo.engine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ planemo.engine package
Submodules
----------

planemo.engine.autoupdate module
--------------------------------

.. automodule:: planemo.engine.autoupdate
:members:
:undoc-members:
:show-inheritance:

planemo.engine.cwltool module
-----------------------------

Expand Down
6 changes: 1 addition & 5 deletions planemo/autoupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ def check_conda(tool_name, ctx, **kwds):
error("Conda is not installed! Try running planemo conda_init.")
target = planemo.conda.conda_util.CondaTarget(tool_name)
search_results = conda_util.best_search_result(target, conda_context=conda_context)
# if search_results[0]['version'] == tool_version:
# return None
# else:
return search_results[0]['version']


Expand Down Expand Up @@ -144,7 +141,6 @@ def perform_required_update(ctx, xml_files, tool_path, requirements, tokens, xml
if wrapper_version_token in v:
xml_to_update[k].append({'type': 'token', 'tag': v[wrapper_version_token]['tag'], 'value': 0})

# print(xml_to_update)
# finally, update each file separately
for k, v in xml_files.items():
update_xml(k, v, xml_to_update[k], wrapper_version_token, is_macro=(k != tool_path))
Expand All @@ -153,7 +149,7 @@ def perform_required_update(ctx, xml_files, tool_path, requirements, tokens, xml
return set(xml_files)


def autoupdate(ctx, tool_path, modified_files=set(), **kwds):
def autoupdate_tool(ctx, tool_path, modified_files=set(), **kwds):
"""
Autoupdate an XML file
"""
Expand Down
9 changes: 4 additions & 5 deletions planemo/commands/cmd_autoupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def skip_requirements_option():
@options.recursive_option()
@test_option()
@skiplist_option()
@skip_requirements_option()
@options.test_options()
@options.galaxy_target_options()
@options.galaxy_config_options()
@options.report_level_option()
@options.report_xunit()
@options.fail_level_option()
@options.skip_option()
@command_function
def cli(ctx, paths, **kwds):
"""Auto-update tool requirements by checking against Conda and updating if newer versions are available."""
Expand All @@ -89,7 +89,7 @@ def cli(ctx, paths, **kwds):
continue
info("Auto-updating tool %s" % tool_path)
try:
updated = autoupdate.autoupdate(ctx, tool_path, modified_files=modified_files, **kwds)
updated = autoupdate.autoupdate_tool(ctx, tool_path, modified_files=modified_files, **kwds)
if updated:
modified_files.update(updated)
except Exception as e:
Expand All @@ -106,14 +106,13 @@ def cli(ctx, paths, **kwds):
else:
with temp_directory(dir=ctx.planemo_directory) as temp_path:
# only test tools in updated directories
modified_paths = [tool_path for tool_path, tool_xml in yield_tool_sources_on_paths(ctx, paths, recursive) if tool_path in modified_files]
modified_paths = [path for path, tool_xml in yield_tool_sources_on_paths(ctx, paths, recursive) if path in modified_files]
info(f"Running tests for the following auto-updated tools: {', '.join(modified_paths)}")
runnables = for_paths(modified_paths, temp_path=temp_path)
kwds["engine"] = "galaxy"
return_value = test_runnables(ctx, runnables, original_paths=paths, **kwds)

exit_codes.append(return_value)
return coalesce_return_codes(exit_codes, assert_at_least_one=assert_tools)
ctx.exit(return_value)


def handle_tool_load_error(tool_path, tool_xml):
Expand Down