Skip to content

Conversation

@bjester
Copy link
Member

@bjester bjester commented Jan 20, 2026

Summary

  • Updates Filter to:
    • separate existing templating mechanism into a factory method for clarity wrt to add and copy operations
    • deduplicate partition filters when adding them
    • have utilities for copying, adding, and checking exact existence of a filter
    • have explicit unit tests, mostly written by Gemini 🤖
  • Updates context classes to:
    • define new .join() interface in parity with .prepare()
    • refactors existing CompositeSessionContext.update() logic into .join()
    • allow modification of sync filters under conditions defined in the issue
    • better test coverage over the affected functionality
  • Adds ignore for Jetbrains project config files

Release notes

  • Deprecates Filter constructor usage utilizing parameters-- use Filter.from_template instead

TODO

  • Have tests been written for the new code?
  • Has documentation been written/updated? no docs mentioned Filter
  • New dependencies (if any) added to requirements file

Reviewer guidance

  1. Ran Kolibri's morango integration tests with these changes: INTEGRATION_TEST=1 pytest -x kolibri/core/auth/test/test_morango_integration.py

Issues addressed

Closes #282

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Tests are almost exclusively additions, so we have good guarantees of consistent behaviour here. The tests that have been updated have mostly been to use real objects instead of mocks, which makes the outcome of the tests feel more robust!

No blockers, just comments and questions!

:param params: DEPRECATED: USE Filter.from_template() INSTEAD
:type params: dict|str
"""
if params is not None:
Copy link
Member

Choose a reason for hiding this comment

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

Worth adding a deprecation warning here, or not worth the effort just to warn us? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I can add that 👍

"""
if other is None:
return self
# create a list of partition filters, deduplicating them between the two filter objects
Copy link
Member

Choose a reason for hiding this comment

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

Almost feels like partitions are more semantically sets rather than lists?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I guess that would make this simpler to just use a set.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I forgot sets don't maintain order. While the Filter class does not explicitly try to preserve that, it does make sense to do so. To avoid adding a dep for OrderedSet, I will leave this as is for now.

result = middleware(prepared_context)

# return the prepared context back
context.join(prepared_context)
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I think this is what I was looking for!

# During the initializing stage, we want to make sure to synchronize the transfer session
# object between the composite and children contexts, using whatever child context's
# transfer session object that was updated on the context during initialization
current_stage = stage or self._stage
Copy link
Member

Choose a reason for hiding this comment

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

So the logic that was here is removed in favour of join, mostly? But with some tweaks? And then join is called...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah since join() is called in nearly the same spot that triggered this code, it made sense to just move this logic to join() and add the new functionality there.

context = TestSessionContext()

sync_filter = mock.Mock(spec=Filter)
sync_filter = Filter("a")
Copy link
Member

Choose a reason for hiding this comment

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

Always feels like a confidence boosting change to switch out a Mock for a real object in a test.

@bjester bjester merged commit b74f896 into learningequality:release-v0.8.x Jan 20, 2026
22 checks passed
@bjester bjester deleted the op-mod-con branch January 20, 2026 23:28
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.

Allow sync operations to modify the sync filter

2 participants