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

Rocoto XML regex fix #643

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Conversation

maddenp-noaa
Copy link
Collaborator

Synopsis

Given rocoto.yaml:

workflow:
  entities:
    GREETING: hello
  attrs:
    realtime: false
    scheduler: slurm
  cycledef:
    - spec: 202410290000 202410300000 06:00:00
  log: logs/test.log
  tasks:
    task_greet:
      command: true && echo &GREETING;
      cores: 1
      walltime: 00:00:10

Current behavior:

$ uw rocoto realize --config-file rocoto.yaml 
[2024-11-01T23:10:42]     INFO 0 UW schema-validation errors found in Rocoto config
...
lxml.etree.XMLSyntaxError: xmlParseEntityRef: no name, line 11, column 20

The problematic line in the XML is:

<command>true &&amp; echo &GREETING;</command>

due to the regex corrected in this PR, which changed a correct &amp;&amp; into &&amp;. The regex is meant to correct mangled entities like &amp;FOO;, which should appear as &FOO; in the XML.

With the change in this PR:

$ uw rocoto realize --config-file rocoto.yaml 
[2024-11-01T23:13:57]     INFO 0 UW schema-validation errors found in Rocoto config
[2024-11-01T23:13:57]     INFO 0 Rocoto XML validation errors found
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE workflow [
  <!ENTITY GREETING "hello">
]>
<workflow realtime="False" scheduler="slurm">
  <cycledef>202410290000 202410300000 06:00:00</cycledef>
  <log>logs/test.log</log>
  <task name="greet">
    <cores>1</cores>
    <walltime>00:00:10</walltime>
    <command>true &amp;&amp; echo &GREETING;</command>
    <jobname>greet</jobname>
  </task>
</workflow>

I think this this command should be interpreted as true && echo hello at run time, but maybe someone with a Rocoto workflow could confirm by e.g. adding true &amp;&amp; to the start of a <command> tag's text, which should have no effect (and, specifically, should cause no error).

Type

  • Bug fix (corrects a known issue)

Impact

  • This is a non-breaking change (existing functionality continues to work as expected)

Checklist

  • I have added myself and any co-authors to the PR's Assignees list.
  • I have reviewed the documentation and have made any updates necessitated by this change.

@maddenp-noaa maddenp-noaa self-assigned this Nov 1, 2024
Copy link
Collaborator

@christinaholtNOAA christinaholtNOAA left a comment

Choose a reason for hiding this comment

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

I'm not a huge fan of how the XML bash command no longer looks very bash-like, but I do appreciate the added resiliency it allows.

@maddenp-noaa maddenp-noaa merged commit 8b835f7 into ufs-community:main Nov 4, 2024
2 checks passed
@maddenp-noaa maddenp-noaa deleted the xml-regex-fix branch November 4, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants