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

ID tokeniser bug #6110

Closed
hjoliver opened this issue May 23, 2024 · 7 comments · Fixed by #6123
Closed

ID tokeniser bug #6110

hjoliver opened this issue May 23, 2024 · 7 comments · Fixed by #6123
Assignees
Labels
could be better Not exactly a bug, but not ideal. small
Milestone

Comments

@hjoliver
Copy link
Member

hjoliver commented May 23, 2024

This is a valid ISO8601 format: 2050-01-01T00:00Z but the tokeniser cuts the :00Z bit off the end, which ends up with the wrong result if your system clock is not UTC or if you have non-zero minutes.

>>> from cylc.flow.id import Tokens

>>> Tokens('foo//20500101T0000Z')
<id: foo//20500101T0000Z>  # good

>>> Tokens('foo//2050-01-01T00:00Z')
<id: foo//2050-01-01T00>  # bug - later this gets interpreted as local time

We disallow this a cycle point format in workflows because : is not a valid character in filenames, but cycle points can be specified on the command line too and then converted to the workflow format.

We have a functional test that does this, and fails for non-UTC clocks: tests/f/workflow-state/06a-noformat.t (for the cylc workflow-state command).

This diff seems to fix the tokeniser (don't disallow ':' in cycle point):

$ git diff
diff --git a/cylc/flow/id.py b/cylc/flow/id.py
index cba3c4833..b9d7cc2e1 100644
--- a/cylc/flow/id.py
+++ b/cylc/flow/id.py
@@ -403,10 +403,10 @@ class Tokens(dict):
 # //cycle[:sel][/task[:sel][/job[:sel]]]
 RELATIVE_PATTERN = rf'''
     //
-    (?P<{IDTokens.Cycle.value}>[^~\/:\n]+)
+    (?P<{IDTokens.Cycle.value}>[^~\/\n]+)
     (?:
       :
-      (?P<{IDTokens.Cycle.value}_sel>[^\/:\n]+)
+      (?P<{IDTokens.Cycle.value}_sel>[^\/\n]+)
     )?
     (?:
       /

Alternatively we might want to detect the : here and raise an error instead, but I can't see any harm in allowing this user-friendly format in CLI and UI queries?

@hjoliver hjoliver added the bug label May 23, 2024
@hjoliver hjoliver added this to the 8.3.x milestone May 23, 2024
@oliver-sanders
Copy link
Member

Should be ok to apply that diff.

@MetRonnie MetRonnie modified the milestones: 8.3.x, 8.3.1 May 23, 2024
@hjoliver
Copy link
Member Author

Actually, the second part of my diff is probably wrong (cycle selector), but made me think:

Does the selector delimiter (:) prevent us from supporting this datetime format on the CLI as well? wflow//*:running, wflow//2010:running ...

@oliver-sanders
Copy link
Member

oliver-sanders commented May 23, 2024

Oh dammit, of course, no we cannot support : in cycle points :(

I don't think it had occurred to me that it was even possible to do so.

It would be kinda possible to hack this in along the lines of your diff above, but really nasty (you would have to attempt to parse the cycle+selector to tell if together they form a valid cycle point, then implement special handling)

@hjoliver
Copy link
Member Author

Let's just disallow that format, across the board.

This still remains a bug though, because the CLI currently accepts the format but handles it badly.

@wxtim wxtim self-assigned this May 31, 2024
@wxtim
Copy link
Member

wxtim commented May 31, 2024

@oliver-sanders - are you happy for me to block this cycle point format on the CLI?

@oliver-sanders
Copy link
Member

oliver-sanders commented May 31, 2024

It already is as the result of this issue. No need for further action.

@wxtim wxtim removed their assignment May 31, 2024
@MetRonnie
Copy link
Member

MetRonnie commented Jun 6, 2024

It already is as the result of this issue. No need for further action.

It is not blocked though, it leads to the command failing to match tasks.

$ cylc hold horse/pamphlet/run1//2012-01-01T00:00Z/foo
Command submitted; the scheduler will log any problems.
INFO - [20120101T0000Z/foo/01:submitted] => running
...
INFO - Command "hold" received. ID=ff867448-fba3-4870-9978-06ec94e9fb7f
    hold(tasks=['2012-01-01T00:00Z/foo'])
WARNING - No active tasks matching: 2012-01-01T00:00Z/foo

@MetRonnie MetRonnie self-assigned this Jun 6, 2024
@MetRonnie MetRonnie added could be better Not exactly a bug, but not ideal. and removed bug labels Jun 6, 2024
@MetRonnie MetRonnie modified the milestones: 8.3.1, 8.3.0 Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
could be better Not exactly a bug, but not ideal. small
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants