Skip to content

Conversation

@MyPyDavid
Copy link
Member

@MyPyDavid MyPyDavid commented May 23, 2025

Description

Related issue: #1360

The incremental signal handling left out some behavior for specific cases in the the synchronization of the projects views or tasks.
For example, when the last catalog of a view is removed it should be available to all catalogs (-> needs to be added to all projects). When a catalog is then added to same view (to an empty views.catalogs), it needs to be added to projects with that catalog and potential removed from other projects.
Now, the architecture has been changed into checking the whole state for all projects on each signal. The incremental design got more complex and need many specific queries.

Test cases were added that explicitly test for the proper behavior.

  • implementation and tests for catalogs

    • view.catalogs
    • task.catalogs
  • implementation and tests for groups

    • view.groups
    • task.groups
  • implementation and tests for sites

    • view.sites
    • task.sites
  • implementation and tests for view.available

  • implementation and tests for task.available

  • handle sync views when project.catalog changes

  • handle sync tasks when project.catalog changes

  • management script sync_projects

    • to sync views on all projects
    • to sync tasks on all projects

PS
I tried out the copilot agent from the codespaces for this (but first suggestion was already a hallucination)

@MyPyDavid MyPyDavid added this to the RDMO 2.3.2 milestone May 23, 2025
@MyPyDavid MyPyDavid self-assigned this May 23, 2025
MyPyDavid added 11 commits June 4, 2025 11:44
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
@MyPyDavid MyPyDavid force-pushed the 1360-taskview-sync-might-be-buggy branch from 3316490 to 23fff15 Compare June 4, 2025 09:44
@MyPyDavid
Copy link
Member Author

rebased to 2.3.2

MyPyDavid added 4 commits June 4, 2025 14:24
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
MyPyDavid added 2 commits June 5, 2025 14:36
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
return self.none()

# projects that have an unavailable catalog should be disregarded
qs = self.filter(catalog__available=True)
Copy link
Member Author

Choose a reason for hiding this comment

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

this is maybe still needs a design decision.
Currently, when a project has a catalog that is unavailable it will be disregarded for syncing.
Is this a typical use-case or does the sync needs to go over all applicable projects anyway? @m6121

Copy link
Member

@jochenklar jochenklar left a comment

Choose a reason for hiding this comment

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

Ok, testes with a lot of projects. And also with the feature disabled. Great work!

)
return

for project in to_remove:
Copy link
Member

Choose a reason for hiding this comment

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

Instead of the loop you can just use instance.projects.remove(*to_remove) here.

MyPyDavid added 4 commits June 6, 2025 11:09
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Copy link
Member

@jochenklar jochenklar left a comment

Choose a reason for hiding this comment

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

Forget the two last messages. I think you can merge now.

@MyPyDavid
Copy link
Member Author

I forgot to add the management script to initialize the synced state with, maybe with a for loop over the views/tasks?

MyPyDavid added 2 commits June 6, 2025 14:49
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
@MyPyDavid MyPyDavid requested a review from jochenklar June 6, 2025 13:24
@MyPyDavid MyPyDavid linked an issue Jun 23, 2025 that may be closed by this pull request
Copy link
Member

@jochenklar jochenklar left a comment

Choose a reason for hiding this comment

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

Again awesome work! I wonder why you use self.stdout.write instread of print?.

if show:
self.show_project_tasks_and_views()
else:
raise CommandError('You must specify at least one of --tasks or --views')
Copy link
Member

Choose a reason for hiding this comment

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

This should include --show.

task_ids = sorted(project.tasks.values_list('id', flat=True))
view_ids = sorted(project.views.values_list('id', flat=True))

self.stdout.write(f'Project(id={project.id}) {project.title}:')
Copy link
Member

Choose a reason for hiding this comment

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

I would format it a bit different:

Project "Test" [id=1]:
- Tasks:
  - http://example.com/terms/tasks/null
  - http://example.com/terms/tasks/text_equal_test
- Views:
  - http://example.com/terms/views/view_a

with

            self.stdout.write(f'Project "{project.title}" [id={project.id}]:')
            if view_uris:
                self.stdout.write('- Tasks:')
                for task_uri in task_uris:
                    self.stdout.write(f'  - {task_uri}')
            if view_uris:
                self.stdout.write('- Views:')
                for view_uri in view_uris:
                    self.stdout.write(f'  - {view_uri}')
            self.stdout.write()

What do you think?

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, with the uris may be better, Ive changed the show method and also adjusted the tests.
I think that the self.stdout.write is better for test-ability with the fixture capsys.readouterr().

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok, but I think they are just the same. see https://docs.pytest.org/en/stable/how-to/capture-stdout-stderr.html#accessing-captured-output-from-a-test-function. No problem here though, just merge.

Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
@MyPyDavid MyPyDavid requested a review from jochenklar June 27, 2025 09:06
@MyPyDavid MyPyDavid merged commit 5b6d955 into 2.3.2 Jun 27, 2025
18 checks passed
@MyPyDavid MyPyDavid deleted the 1360-taskview-sync-might-be-buggy branch June 27, 2025 12:47
@MyPyDavid MyPyDavid mentioned this pull request Jul 2, 2025
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.

Task/View sync might be buggy

3 participants