Skip to content

uis subscription data sync info (UIS-597) - #6113

Open
dwsutherland wants to merge 10 commits into
cylc:masterfrom
dwsutherland:uis-minimal-data-sync-uis597
Open

uis subscription data sync info (UIS-597)#6113
dwsutherland wants to merge 10 commits into
cylc:masterfrom
dwsutherland:uis-minimal-data-sync-uis597

Conversation

@dwsutherland

@dwsutherland dwsutherland commented May 29, 2024

Copy link
Copy Markdown
Member

sibling of cylc/cylc-uiserver#597

Have included testing some of the changes, however the parts not tested are used by cylc-uiserver not cylc-flow.

This end is to:

  • hook into resolvers to extract which workflows a subscription/query is targeting
  • adds an API endpoint and store stub

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.cfg (and conda-environment.yml if present).
  • Tests included (limited), as functionality is only used UIS side.
  • CHANGES.md entry included if this is a change that can affect users
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@dwsutherland dwsutherland self-assigned this May 29, 2024
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from 50e7c94 to 2e63d5e Compare May 30, 2024 07:09
@dwsutherland dwsutherland added this to the 8.3.0 milestone May 30, 2024
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from 0d033e1 to 1dee25b Compare May 30, 2024 09:16
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch 2 times, most recently from b86c3e4 to 542ccc6 Compare June 12, 2024 01:27
@dwsutherland dwsutherland modified the milestones: 8.3.0, 8.4.0 Jun 18, 2024
@oliver-sanders oliver-sanders modified the milestones: 8.4.0, 8.5.0 Nov 29, 2024
@oliver-sanders oliver-sanders modified the milestones: 8.5.0, 8.x Mar 28, 2025
@oliver-sanders

oliver-sanders commented Aug 18, 2025

Copy link
Copy Markdown
Member

Reminder (largely for myself): This PR is pending an upstream implementation in cylc-uiserver.

Drafting for now as this code may change in relation to upstream requirements.

@oliver-sanders
oliver-sanders marked this pull request as draft August 18, 2025 14:51
@oliver-sanders

Copy link
Copy Markdown
Member

(unassigning this to re-focus my review queue, feel free to re-assign when undrafted)

@oliver-sanders
oliver-sanders removed their request for review February 19, 2026 12:53
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from 542ccc6 to ac312a7 Compare March 4, 2026 08:36
@dwsutherland dwsutherland modified the milestones: 8.x, 8.7.0 Mar 4, 2026
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from ac312a7 to 3369d88 Compare March 12, 2026 09:31
@dwsutherland
dwsutherland marked this pull request as ready for review March 12, 2026 09:45
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from 3369d88 to e4a2eed Compare March 13, 2026 07:41
@dwsutherland

Copy link
Copy Markdown
Member Author

Don't think the lint failure is relevant:

Exception: HTTP Error 429: Too Many Requests

@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch 2 times, most recently from 685725a to bfade96 Compare March 27, 2026 07:59
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from bfade96 to 8666039 Compare April 3, 2026 09:15
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from 8666039 to a3cad8f Compare April 21, 2026 03:38
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from a3cad8f to 82696b0 Compare May 1, 2026 03:24
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from 82696b0 to eb1c6ed Compare May 1, 2026 03:26
@dwsutherland dwsutherland removed the small label May 1, 2026
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch 4 times, most recently from 0a3398b to af67840 Compare May 8, 2026 03:14
@dwsutherland dwsutherland mentioned this pull request May 10, 2026
8 tasks
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from af67840 to 8c0552f Compare May 13, 2026 10:17
@oliver-sanders
oliver-sanders requested review from hjoliver and removed request for hjoliver June 8, 2026 09:56

@oliver-sanders oliver-sanders left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As I understand it:

  • When a subscription is started, or a query is issued, the timer field is set.
  • Once the timeout has elapsed, the subscription will be recalculated.
  • (When a subscription is stopped, we should also set the timer, but I'm not sure we currently are?)

Just wondering if it might be easier to add hook methods, e.g, query_issues, subscription_started, subscription_stopped to avoid having to set and track these timeouts, e.g:

def  query_issued(self, w_id):
    self.loop.call_later(TIMEOUT, self.recalculate_subscription, w_id)

def  subscription_stopped(self, w_id):
    self.loop.call_later(TIMEOUT, self.recalculate_subscription, w_id)

Comment on lines +356 to +370
data_store[w_id]
for w_id in iter_uniq(w_ids)
if w_id in data_store
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the same as the existing function, just with the addition of the await self.data_store_mgr.set_query_sync_levels(set(w_ids)) bit.

Consequently, we have to duplicate the if is_sub: ...; else logic to toggle between these two implementations for all uses below.

I think we can simplify things by merging the two implementations like so:

async def get_flow_data_from_ids(self, data_store, native_ids, is_sub):
    w_ids = {Tokens(w_id).workflow_id for w_id in native_ids}
    if is_sub:
        await self.data_store_mgr.set_query_sync_levels(w_ids)
    return [data_store[w_id] for w_id in w_ids if w_id in data_store]

Then pass trough a bool flag to toggle:

flow_data = get_flow_data_from_ids(
    self.data_store_mgr.data,
    nat_ids,
    bool(args['delta_store'])
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will have to check if it needs to be order preserving (i.e. for tests), but yeah maybe a list would work the same for query sync level setting.

@dwsutherland dwsutherland Jun 19, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Although there may be some simplification not thought of, both calls also pass in a different store: self.delta_store[args['sub_id']] and self.data_store_mgr.data according to args['delta_store']..

And although args['delta_store'] implies is_sub, some subs resolve from the main store self.data_store_mgr.data .. So bool(args['delta_store']) can be False while is_sub is True.

(I did attempt simplification for a while.. but got stuck on this compication)

Comment thread cylc/flow/network/server.py Outdated
@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from 8c0552f to 98b95e7 Compare June 17, 2026 10:44
@dwsutherland

dwsutherland commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

As I understand it:

  • When a subscription is started, or a query is issued, the timer field is set.
  • Once the timeout has elapsed, the subscription will be recalculated.
  • (When a subscription is stopped, we should also set the timer, but I'm not sure we currently are?)

Off the top of my head, there's no timer on subscriptions (stays up for as long as the subscription is active), however, the query timer trumps the subscription.. So once the query timer is spent, it falls back to the subscription..

The query data types are added to the level for the duration of the timer, and then the subscription topics are determined from this, both when the query is made and when the timer finishes..

@dwsutherland

Copy link
Copy Markdown
Member Author

Back compatibility in:
cylc/cylc-uiserver#597 (comment)

@dwsutherland
dwsutherland force-pushed the uis-minimal-data-sync-uis597 branch from a4f9e31 to bc916d6 Compare June 22, 2026 05:50
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.

2 participants