id
int64
0
1.29M
original_id
stringlengths
32
32
swhid
stringlengths
100
170
sha1
stringlengths
40
40
repo_name
stringlengths
2
45
repo_group
stringclasses
12 values
filepath
stringlengths
5
153
name
stringlengths
1
14.9k
type
stringclasses
3 values
code
stringlengths
7
2.12M
1,600
6c8d3d52cc55e3609e8f3b45855fcb5d
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=77-89/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_skipped_records_drift_target(self)
function
def test_skipped_records_drift_target(self) -> None: """User in skip list is SKIPPED, but the action records what the target WOULD have been so audit logs show suppressed drift.""" plan = diff( current_members={"a@x": _member("a@x", Role.ADMIN)}, target_states={"a@x": _ta...
1,601
ba1bf30e607e55bb1bab374dfc6fd1fd
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=99-106/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_skip_list_for_bitu_only_users_emits_skipped(self)
function
def test_skip_list_for_bitu_only_users_emits_skipped(self) -> None: plan = diff( current_members={}, target_states={"newhire@x": _target(Role.READ_ONLY)}, skip_emails={"newhire@x"}, ) assert plan.counts()[ActionKind.SKIPPED] == 1 assert plan.counts()[A...
1,602
ea386a948e63ef289a1d02edbcdb50c4
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=117-140/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_provenance_fields_propagated(self)
function
def test_provenance_fields_propagated(self) -> None: target = TargetState( role=Role.ADMIN, rule_number=2, source_bitu_groups=frozenset({"GrowthBook-Admin"}), source_posix_groups=frozenset({"analytics-privatedata-users"}), ) plan = diff( ...
1,603
609df48e55a15fc3499e6d5e39e553c2
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=142-144/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_empty_inputs_produce_empty_plan(self)
function
def test_empty_inputs_produce_empty_plan(self) -> None: plan = diff(current_members={}, target_states={}, skip_emails=set()) assert plan.actions == ()
1,604
11bad66ca8186b310b12eed517e128bd
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=156-162/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiffEmailNormalization::test_uppercase_in_target_states_raises(self)
function
def test_uppercase_in_target_states_raises(self) -> None: with pytest.raises(ValueError, match="non-lowercase"): diff( current_members={}, target_states={"NewHire@x": _target(Role.READ_ONLY)}, skip_emails=set(), )
1,605
2ac4e7c6b4197d56efa6996723d52d8f
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=164-170/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiffEmailNormalization::test_uppercase_in_skip_emails_raises(self)
function
def test_uppercase_in_skip_emails_raises(self) -> None: with pytest.raises(ValueError, match="non-lowercase"): diff( current_members={}, target_states={}, skip_emails={"Skip@x"}, )
1,606
16a11822b36362d675dfb6be63a30e41
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=199-210/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestSortOrder::test_inner_order_within_removes_is_current_role_desc_then_email(self)
function
def test_inner_order_within_removes_is_current_role_desc_then_email(self) -> None: """Within REMOVE category, most over-privileged users get neutered first; ties broken by email asc.""" actions = ( Action("a@x", ActionKind.REMOVE, Role.READ_ONLY, Role.NO_ACCESS, 0), Actio...
1,607
5117b941e7ef5d7f2d64e296905be4e3
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=212-218/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestSortOrder::test_sort_is_deterministic(self)
function
def test_sort_is_deterministic(self) -> None: actions_1 = ( Action("a@x", ActionKind.REMOVE, Role.ADMIN, Role.NO_ACCESS, 0), Action("b@x", ActionKind.REMOVE, Role.READ_ONLY, Role.NO_ACCESS, 0), ) actions_2 = tuple(reversed(actions_1)) assert Plan(actions=actions_1...
1,608
024bfc18f5c3c8a7cf12a30d15bbec7b
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=22-144/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff
type
# ---- diff() classification ---- class TestDiff: def test_noop_when_current_matches_target(self) -> None: plan = diff( current_members={"a@x": _member("a@x", Role.READ_ONLY)}, target_states={"a@x": _target(Role.READ_ONLY)}, skip_emails=set(), ) assert p...
1,609
8e6775f3297c6e7a7ef844cbf9a62c50
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=147-170/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiffEmailNormalization
type
class TestDiffEmailNormalization: def test_uppercase_in_current_members_raises(self) -> None: with pytest.raises(ValueError, match="non-lowercase"): diff( current_members={"A@x": _member("A@x", Role.READ_ONLY)}, target_states={}, skip_emails=set(),...
1,610
6ae2aee7b2248369c3af666687966bd1
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=173-218/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestSortOrder
type
# ---- Sort order (apply order) ---- class TestSortOrder: def test_outer_order_includes_all_six_kinds(self) -> None: """sorted_actions returns REMOVE -> UPDATE -> ADD -> NOOP -> SKIPPED -> PENDING_SSO.""" actions = ( Action("z@x", ActionKind.PENDING_SSO, Role.NO_ACCESS, Role.RE...
1,611
8ad13ef66930a4c8a08770fc3884e6fb
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=143-154/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestCustomElevatedAccess::test_elevated_without_prereq_but_in_readonly_falls_through_to_readonly( self, )
function
def test_elevated_without_prereq_but_in_readonly_falls_through_to_readonly( self, ) -> None: """If CustomElevatedAccess rule doesn't qualify but ReadOnly does, the user gets READ_ONLY (the elevated rule is silently skipped).""" state = compute_target_state( user_uid="jdoe...
1,612
5fda583e307ea7826ac2c36479f93c1e
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=57-66/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestPosixGate::test_no_privatedata_means_no_access(self, bitu: frozenset[str])
function
def test_no_privatedata_means_no_access(self, bitu: frozenset[str]) -> None: # User has all elevated POSIX groups but is missing privatedata. posix = _posix("jdoe", list(ELEVATED_POSIX_GROUPS)) state = compute_target_state( user_uid="jdoe", bitu_memberships=bitu, ...
1,613
4e368cb2ec275a8001c8954c98d4867a
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=105-112/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestAdmin::test_admin_plus_elevated_with_prereq_max_wins(self)
function
def test_admin_plus_elevated_with_prereq_max_wins(self) -> None: state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_ADMIN_GROUP, BITU_ELEVATED_GROUP}), posix_memberships=_posix("jdoe", [PRIVATE_DATA_GROUP, "deployment"]), ) assert ...
1,614
627d63187d1e390b75aef73a7b8fab67
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=156-163/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestCustomElevatedAccess::test_elevated_with_prereq_plus_readonly_max_wins(self)
function
def test_elevated_with_prereq_plus_readonly_max_wins(self) -> None: state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_ELEVATED_GROUP, BITU_READONLY_GROUP}), posix_memberships=_posix("jdoe", [PRIVATE_DATA_GROUP, "analytics-product-users"]), ...
1,615
07fb96706eba01723c01f7a2d90f87a8
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=297-306/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestProvenance::test_provenance_empty_on_posix_gate_short_circuit(self)
function
def test_provenance_empty_on_posix_gate_short_circuit(self) -> None: """When the POSIX gate trips, source provenance is left empty — the resolver short-circuited before computing it.""" state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_ADMIN_...
1,616
8bc37cf64bd6d6a4a1d3267199069ecd
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=210-218/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestNoBituMembership::test_in_privatedata_but_no_bitu_groups(self)
function
def test_in_privatedata_but_no_bitu_groups(self) -> None: """User has POSIX gate but no Bitu group → NO_ACCESS / NO_MATCH.""" state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset(), posix_memberships=_posix("jdoe", [PRIVATE_DATA_GROUP, "deployment...
1,617
0e80e6039bbd1a53917c7701a7cd4736
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=28-30/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
_posix(uid: str, groups: list[str])
function
def _posix(uid: str, groups: list[str]) -> dict[str, set[str]]: """Build a posix_memberships map where `uid` is in each named group.""" return {g: {uid} for g in groups}
1,618
bcbdc50b62ff9a9cd27e5153449fc133
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=68-75/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestPosixGate::test_empty_posix_means_no_access(self)
function
def test_empty_posix_means_no_access(self) -> None: state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_ADMIN_GROUP}), posix_memberships={}, ) assert state.role == Role.NO_ACCESS assert state.rule_number == RULE_POSIX_GATE
1,619
7ae3abfb68539b915f990248d4194600
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=220-228/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestNoBituMembership::test_completely_empty(self)
function
def test_completely_empty(self) -> None: state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset(), posix_memberships={}, ) assert state.role == Role.NO_ACCESS # Empty posix → POSIX gate trips first. assert state.rule_number =...
1,620
44ad5f3d39431cf6f462b602b91307aa
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=241-255/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestMultiUserPosixMaps::test_other_users_in_groups_dont_affect_target(self)
function
def test_other_users_in_groups_dont_affect_target(self) -> None: posix = { PRIVATE_DATA_GROUP: {"jdoe", "asmith", "bjones"}, "deployment": {"asmith"}, # NOT jdoe } # jdoe is in privatedata but NOT in any elevated POSIX, even though # asmith is in deployment. ...
1,621
8465faf32c6b5553e35d5bae04add775
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=84-93/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestAdmin::test_admin_alone(self)
function
def test_admin_alone(self) -> None: state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_ADMIN_GROUP}), posix_memberships=_posix("jdoe", [PRIVATE_DATA_GROUP]), ) assert state.role == Role.ADMIN assert state.rule_number == RUL...
1,622
ce74a1e1f725861ca89ecdfd19c4b45a
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=95-103/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestAdmin::test_admin_with_readonly_max_wins(self)
function
def test_admin_with_readonly_max_wins(self) -> None: """Admin + ReadOnly memberships → ADMIN via max().""" state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_ADMIN_GROUP, BITU_READONLY_GROUP}), posix_memberships=_posix("jdoe", [PRIVATE_DAT...
1,623
ed26b634d66484770ee5cbbd98cb55f9
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=122-129/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestCustomElevatedAccess::test_elevated_with_each_qualifying_posix(self, elevated_group: str)
function
def test_elevated_with_each_qualifying_posix(self, elevated_group: str) -> None: state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_ELEVATED_GROUP}), posix_memberships=_posix("jdoe", [PRIVATE_DATA_GROUP, elevated_group]), ) assert ...
1,624
ac0a17548e34d7588300a3752f517e52
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=183-190/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestReadOnly::test_readonly_alone(self)
function
def test_readonly_alone(self) -> None: state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_READONLY_GROUP}), posix_memberships=_posix("jdoe", [PRIVATE_DATA_GROUP]), ) assert state.role == Role.READ_ONLY assert state.rule_num...
1,625
f17081631258f4e9dd8cb2711702bbb2
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=131-141/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestCustomElevatedAccess::test_elevated_without_qualifying_posix_falls_through_to_no_access(self)
function
def test_elevated_without_qualifying_posix_falls_through_to_no_access(self) -> None: """In Bitu elevated group but missing required POSIX → CustomElevatedAccess rule does not match. With no other Bitu group, target is NO_ACCESS with rule_number = RULE_NO_MATCH (not POSIX_GATE — privatedata is se...
1,626
c1ccd13eaf3d7c2e5ba437834c868c00
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=165-174/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestCustomElevatedAccess::test_elevated_with_multiple_qualifying_posix(self)
function
def test_elevated_with_multiple_qualifying_posix(self) -> None: state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_ELEVATED_GROUP}), posix_memberships=_posix( "jdoe", [PRIVATE_DATA_GROUP, "analytics-product-users", ...
1,627
e55862a9695c58e7d820fcb5b878dc31
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=192-201/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestReadOnly::test_readonly_does_not_require_extra_posix(self)
function
def test_readonly_does_not_require_extra_posix(self) -> None: """Unlike CustomElevatedAccess, ReadOnly only needs Bitu membership + the privatedata gate. No additional POSIX qualification.""" state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_...
1,628
79ef1abc1ba3fc4e153f3b136d81ccf8
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=267-281/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestProvenance::test_source_groups_include_only_relevant_bitu(self)
function
def test_source_groups_include_only_relevant_bitu(self) -> None: """Only GrowthBook-* groups appear in source_bitu_groups, not unrelated Bitu groups the user happens to be in.""" state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset( { ...
1,629
4d482c8def4accf419a177e9efef78e1
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=283-295/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestProvenance::test_source_groups_include_only_relevant_posix(self)
function
def test_source_groups_include_only_relevant_posix(self) -> None: """Only POSIX groups material to the rules appear in source_posix_groups.""" state = compute_target_state( user_uid="jdoe", bitu_memberships=frozenset({BITU_ELEVATED_GROUP}), posix_memberships={...
1,630
520c4c0f5913387e999d4042f398bab3
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=33-75/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestPosixGate
type
# --------------------------------------------------------------------------- # POSIX gate (hard precondition) # --------------------------------------------------------------------------- class TestPosixGate: """If the user is not in analytics_privatedata_users, target is NO_ACCESS regardless of any Bitu gro...
1,631
90b650742236f384a734223594bdec14
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=78-112/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestAdmin
type
# --------------------------------------------------------------------------- # Admin tier (rule 2) # --------------------------------------------------------------------------- class TestAdmin: def test_admin_alone(self) -> None: state = compute_target_state( user_uid="jdoe", bitu...
1,632
22395f9cc336c86e5e5995d111fcfdf0
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=115-174/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestCustomElevatedAccess
type
# --------------------------------------------------------------------------- # CustomElevatedAccess tier (rule 3) # --------------------------------------------------------------------------- class TestCustomElevatedAccess: @pytest.mark.parametrize("elevated_group", sorted(ELEVATED_POSIX_GROUPS)) def test_el...
1,633
98f230026f30343ca667ee80255b4061
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=177-201/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestReadOnly
type
# --------------------------------------------------------------------------- # ReadOnly tier (rule 4) # --------------------------------------------------------------------------- class TestReadOnly: def test_readonly_alone(self) -> None: state = compute_target_state( user_uid="jdoe", ...
1,634
2484104c093c2779799c99dcb7166c52
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=204-228/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestNoBituMembership
type
# --------------------------------------------------------------------------- # No-Bitu-membership cases # --------------------------------------------------------------------------- class TestNoBituMembership: def test_in_privatedata_but_no_bitu_groups(self) -> None: """User has POSIX gate but no Bitu gr...
1,635
582d20ddc7a42ceb7b48dc06765b35c7
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=231-255/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestMultiUserPosixMaps
type
# --------------------------------------------------------------------------- # Multi-user posix maps # --------------------------------------------------------------------------- class TestMultiUserPosixMaps: """The posix_memberships dict maps group → set of uids. Verify we correctly identify *this* user's m...
1,636
6279ed4cfd94f9359d310343bb64309d
swh:1:cnt:7142dea7e88b69072dfea068d16d276aae18de56;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=258-306/
26bd7b7e925c7f0a61e9ce2afdb4571b31fc861b
growthbook
analytics
ldap-sync/tests/test_resolver.py
TestProvenance
type
# --------------------------------------------------------------------------- # Provenance fields # --------------------------------------------------------------------------- class TestProvenance: """source_bitu_groups and source_posix_groups should reflect the user's actual relevant memberships, not the rul...
1,637
1be62f14656f7dca3d010a033e37a3e6
swh:1:cnt:671dca7568868df23891d27632450f88340d9d83;origin=https://gitlab.wikimedia.org/repos/data-engineering/pipelines.git;lines=8-17/
9b937fb0311bafb2d82d1dfbd0737b682fe4b5f6
pipelines
analytics
commons-impact/parse_category_graph.py
parse_args(args)
function
def parse_args(args) -> argparse.Namespace: parser = argparse.ArgumentParser( description=""" Efficiently parses a large set of edges into a list of vertices. Each vertex has a list of paths that lead up to it and knows if it's in a cycle. """ ) parser.add_argument('-...
1,638
f1e2be06cdd5124271a7661a62a6d649
swh:1:cnt:671dca7568868df23891d27632450f88340d9d83;origin=https://gitlab.wikimedia.org/repos/data-engineering/pipelines.git;lines=45-55/
9b937fb0311bafb2d82d1dfbd0737b682fe4b5f6
pipelines
analytics
commons-impact/parse_category_graph.py
main()
function
def main() -> None: args = parse_args(sys.argv[1:]) spark = SparkSession.builder.getOrCreate() build_graph( spark, args.snapshot ) spark.stop()
1,639
35a38f5daa6ec6a4ba94a08db6bb363e
swh:1:cnt:671dca7568868df23891d27632450f88340d9d83;origin=https://gitlab.wikimedia.org/repos/data-engineering/pipelines.git;lines=20-42/
9b937fb0311bafb2d82d1dfbd0737b682fe4b5f6
pipelines
analytics
commons-impact/parse_category_graph.py
build_graph( spark, snapshot)
function
def build_graph( spark, snapshot) -> None: cl = spark.sql(f""" select cl_from, cl_to, cl_from_type from milimetric.commons_categorylinks """).repartition(512) edges = cl.select( cl.cl_from.alias('dst'), cl.cl_to.alias('src'), ) v...
1,640
657784e2c15ddad23b3525eca8ba7c58
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=24-326/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer
type
/** * A high-level Kafka consumer implementation. * * This class provides methods to: * - Subscribe to Kafka topics * - Consume messages in a loop * - Handle consumer rebalancing * - Process messages with error handling * - Graceful shutdown on termination signals */ class KafkaConsumer { /** @var RdKafka\...
1,641
be43d31facee2c80e090220221709927
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=45-64/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::__construct(array $config = [])
function
/** * Initializes a new Kafka consumer with the provided configuration. * * @param array $config Optional configuration array that will be merged with default configuration * @throws \RdKafka\Exception If consumer initialization fails */ public function __construct(array $config = []) {...
1,642
f11958536ecc98e8c6ce115894d14180
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=171-210/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::processMessage(RdKafka\Message $message)
function
/** * Processes a single message received from Kafka. * * Extracts message details and passes them to handleMessage() for processing. * Handles message acknowledgment if auto-commit is disabled. * * @param \RdKafka\Message $message The message received from Kafka * @return void *...
1,643
4cffdf366a05b07ec02f6a86a55e70d3
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=112-125/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::subscribe(array $topics)
function
/** * Subscribes to the specified list of topics. * * The consumer will automatically handle partition assignment and rebalancing. * * @param string[] $topics Array of topic names to subscribe to * @return void * @throws \RdKafka\Exception If subscription fails */ public func...
1,644
7be67fe9e45d72aa40cc9a0164a648e9
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=127-169/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::consume(int $timeoutMs = 1000)
function
/** * Starts the consumer loop to process messages from subscribed topics. * * This method runs indefinitely until the consumer is stopped via SIGTERM or SIGINT. * It handles message consumption, error conditions, and cleanup. * * @param int $timeoutMs Maximum time to block waiting for a m...
1,645
643c3d4d8ae2ded839ebe46abbc10ee8
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=66-110/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::initConsumer()
function
/** * Initializes the Kafka consumer with the configured settings. * * This method sets up: * - Configuration parameters * - Error callback * - Rebalance callback * * @return void * @throws \RdKafka\Exception If consumer creation fails */ private function initConsum...
1,646
7471895a0823e061a4b24e75ea230542
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=212-236/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::handleMessage(array $data)
function
/** * Handles a single message by outputting its details. * * This is a basic implementation that outputs message details to stdout. * Override this method in a child class to implement custom message handling. * * @param array $data Message * @return void */ protected funct...
1,647
62e9b13415b65f980db258b2a6ee9846
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=238-255/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::getHeaders(RdKafka\Message $message)
function
/** * Extracts headers from a Kafka message. * * @param \RdKafka\Message $message * @return array<string, mixed> Associative array of message headers */ private function getHeaders(RdKafka\Message $message): array { $headers = []; if (method_exists($message, 'h...
1,648
90c59a0964a78e71891c71762085ac7b
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=257-272/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::formatPartitions(?array $partitions)
function
/** * Formats an array of topic partitions into a human-readable string. * * @param array|null $partitions Array of RdKafka\TopicPartition objects or null * @return string Formatted string representation of partitions */ private function formatPartitions(?array $partitions): string { ...
1,649
7418a5a26359ada0ffc9f11cb9b72a41
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=274-283/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::shutdown()
function
/** * Gracefully shuts down the consumer. * * @return void */ public function shutdown(): void { $this->logInfo('Shutting down consumer...'); $this->running = false; }
1,650
f9eaf36122f92c3fdfe1fe2a71d08f47
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=285-295/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::close()
function
/** * Closes the Kafka consumer and releases all resources. * * @return void * @throws \RdKafka\Exception If closing the consumer fails */ public function close(): void { $this->consumer->close(); $this->logInfo('Consumer closed'); }
1,651
5f611843521ca9311725cef5379acf8a
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=307-315/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::logError(string $message)
function
/** * * @param string $message The error message to log * @return void */ private function logError(string $message): void { echo sprintf("[%s] ERROR: %s\n", date('Y-m-d H:i:s'), $message); }
1,652
75f97395a3ccc3e619d78380765ea6a9
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=297-305/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::logInfo(string $message)
function
/** * * @param string $message The message to log * @return void */ private function logInfo(string $message): void { echo sprintf("[%s] INFO: %s\n", date('Y-m-d H:i:s'), $message); }
1,653
56ad2c428ee19bd24a4aed88fd140f2a
swh:1:cnt:c947117ed16240aaf15c2c055c447a863b2e6a89;origin=https://gitlab.wikimedia.org/repos/data-engineering/php-kafka-consumer.git;lines=317-325/
2771db564081476d2016cb5c06d5e340019af679
php-kafka-consumer
analytics
consumer.php
KafkaConsumer::logDebug(string $message)
function
/** * * @param string $message The debug message to log * @return void */ private function logDebug(string $message): void { echo sprintf("[%s] DEBUG: %s\n", date('Y-m-d H:i:s'), $message); }
1,654
aed85632cca265846d85da8d2489dbf6
swh:1:cnt:df20dd68083cd04b89c5e6e8e785d22184979729;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=16-154/
205ca69a755ce3d538f23190e916b5abd79e91c0
eventgate
analytics
app.js
initApp
function
/** * Creates an express app and initialises it * * @param {Object} options the options to initialise the app with * @return {Promise<express.Express>} the promise resolving to the app object */ async function initApp(options) { // the main application object const app = express(); const serviceUtils = awa...
1,655
1cf63a2ed4106dc7284411ad1053b3fc
swh:1:cnt:df20dd68083cd04b89c5e6e8e785d22184979729;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=156-215/
205ca69a755ce3d538f23190e916b5abd79e91c0
eventgate
analytics
app.js
loadRoutes
function
/** * Loads all routes declared in routes/ into the app * * @param {Express.Application} app the application object to load routes into * @param {string} dir routes folder * @return {Promise<express.Express>} a promise resolving to the app object */ async function loadRoutes(app, dir) { // recursively load r...
1,656
668781cce7ed604de33591b81a83ab8f
swh:1:cnt:df20dd68083cd04b89c5e6e8e785d22184979729;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=217-255/
205ca69a755ce3d538f23190e916b5abd79e91c0
eventgate
analytics
app.js
createServer
function
/** * Creates and start the service's web server * * @param {ServiceUtilsExpress} app the app object to use in the service * @return {Promise<http.Server>} a promise creating the web server */ function createServer(app) { // return a promise which creates an HTTP server, // attaches the app to it, and star...
1,657
e88b8edd466c0d55ff18efa88f9940a8
swh:1:cnt:a6fbfc8809be780f0f73f15587a4c3dee10821ed;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=5-39/
efecb1e81186714506b3a469cdb626e844dbdd42
eventgate
analytics
lib/api-util.js
setupApiTemplates
function
// --- BEGIN EventGate modification --- // Remove unused functions // --- END EventGate modification --- /** * Sets up the request templates for MW and RESTBase API requests * * @param {!Application} app the application object */ function setupApiTemplates(app) { // set up the MW API request template if (!app....
1,658
8a418754cebdb139c6e2133afd2a6dca
swh:1:cnt:08d4858b4509bca2064c52a47c09be48d1663d26;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=3-31/
07d8fdf87cffa201b522c169c00c572abf0505a3
eventgate
analytics
lib/error.js
ContextualError
type
/** * Error class that takes extra context object and copies * The object's keys to itself. This makes wrapping * Errors easier, via new ContextualError(msg, originalError); * This class also sets a property 'name' that matches * the classes constructor, so you can more easily see the type of error * in logging....
1,659
e8b3fdb4dfd9ad10c3d7785e4ad426f6
swh:1:cnt:08d4858b4509bca2064c52a47c09be48d1663d26;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=49-52/
07d8fdf87cffa201b522c169c00c572abf0505a3
eventgate
analytics
lib/error.js
EventSchemaLoadError
type
/** * Thrown if an event's schema cannot be loaded. */ class EventSchemaLoadError extends ContextualError {}
1,660
230d5b66f10569065b11969c2772ef1c
swh:1:cnt:08d4858b4509bca2064c52a47c09be48d1663d26;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=54-57/
07d8fdf87cffa201b522c169c00c572abf0505a3
eventgate
analytics
lib/error.js
EventSchemaUriMissingError
type
/** * Thrown if a schema URI cannot be extracted from an event. */ class EventSchemaUriMissingError extends ContextualError {}
1,661
78e51cd4c97e7e01238e31b157e1beb6
swh:1:cnt:08d4858b4509bca2064c52a47c09be48d1663d26;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=59-62/
07d8fdf87cffa201b522c169c00c572abf0505a3
eventgate
analytics
lib/error.js
PropertyNotFoundError
type
/** * Thrown by the event-utils objectGet function. */ class PropertyNotFoundError extends ContextualError {}
1,662
9d0f032038c0a152e761015f64eae9f6
swh:1:cnt:08d4858b4509bca2064c52a47c09be48d1663d26;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=33-47/
07d8fdf87cffa201b522c169c00c572abf0505a3
eventgate
analytics
lib/error.js
ValidationError
type
/** * Should be thrown when an event fails schema validation. * This is caught by EventGate to classify event process status. */ class ValidationError extends ContextualError { /** * @param {string} message about what caused the invalid error * @param {Array} errors AJV errors that caused event validat...
1,663
9b1bc45dce417c61d5eff98f258553eb
swh:1:cnt:08d4858b4509bca2064c52a47c09be48d1663d26;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=64-67/
07d8fdf87cffa201b522c169c00c572abf0505a3
eventgate
analytics
lib/error.js
MissingFieldError
type
/** * Thrown by event-utils makeExtractField funciton. */ class MissingFieldError extends Error {}
1,664
da9eac1d42a5b39228d411cd151e7c8f
swh:1:cnt:08d4858b4509bca2064c52a47c09be48d1663d26;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=12-30/
07d8fdf87cffa201b522c169c00c572abf0505a3
eventgate
analytics
lib/error.js
ContextualError::constructor
function
/** * @param {string} message * @param {Object} context */ constructor(message, context) { super(message); // Copy each extra property to this. if (context) { Object.assign(this, context); } Object.defineProperty(this, 'name', { value:...
1,665
e2a06584f9d9c9053bdc2195cd5cc561
swh:1:cnt:08d4858b4509bca2064c52a47c09be48d1663d26;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=38-46/
07d8fdf87cffa201b522c169c00c572abf0505a3
eventgate
analytics
lib/error.js
ValidationError::constructor
function
/** * @param {string} message about what caused the invalid error * @param {Array} errors AJV errors that caused event validation to fail */ constructor(message, errors) { super(message); this.errors = errors; this.errorsText = errors.map((err) => `'${err.dataPath}' ${err.mess...
1,666
38804b4a72b19e80d5582ca3720de59d
swh:1:cnt:1e955510a77e9a8b082e8cb4b25c455366128fd8;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=10-28/
f9cb05b3c36c97e1fb323891b23c10c0d2b4d895
eventgate
analytics
lib/event-util.js
objectGet
function
/** * A wrapper around lodash.get that throws PropertyNotFoundError * if no default value was given, and lodash.get returns undefined. * * @param {Object} object * @param {string} path * @param {any} defaultValue * @return {any} * @throws {PropertyNotFoundError} if Object does not have path and no default given...
1,667
23f6c3b6d1a0f4c730e37612fa8c73df
swh:1:cnt:1e955510a77e9a8b082e8cb4b25c455366128fd8;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=51-78/
f9cb05b3c36c97e1fb323891b23c10c0d2b4d895
eventgate
analytics
lib/event-util.js
makeExtractField
function
/** * Returns a function that calls objectFindAndGet and throws * an event specific error if the field(s) is missing. * * @param {Array|string} field path (or paths) to look for in event * @param {any} defaultValue * @return {function(Object, Object): any} */ function makeExtractField(field, defaultValue) { ...
1,668
6c9778dca94301eb0c9bc97dd147b713
swh:1:cnt:1e955510a77e9a8b082e8cb4b25c455366128fd8;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=80-97/
f9cb05b3c36c97e1fb323891b23c10c0d2b4d895
eventgate
analytics
lib/event-util.js
stringMatches
function
/** * Returns true if subject matches pattern. If pattern is * a RegExp or looks like one (starts and ends with /), then * it will be tested against subject. Otherwise subject === pattern. * * @param {string} subject * @param {string|RegExp} pattern * @return {boolean} */ function stringMatches(subject, patter...
1,669
b448c482228eda5a2d1dcf3430a64dfe
swh:1:cnt:1e955510a77e9a8b082e8cb4b25c455366128fd8;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=30-49/
f9cb05b3c36c97e1fb323891b23c10c0d2b4d895
eventgate
analytics
lib/event-util.js
objectFindAndGet
function
/** * Given an array of paths, this searches the object for the first * defined path and returns it using objectGet. * * @param {Object} object * @param {Array|string} paths * @param {any} defaultValue * @return {any} * @throws {PropertyNotFoundError} if Object does not have any path */ function objectFindAndG...
1,670
338bed1447cace67bdb90e50d7750ee5
swh:1:cnt:dc4be6aee50ae906c02e45eb9efccbaa5c8a8689;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=11-60/
79d5af07d1c27699523a169eee1d6c095b700773
eventgate
analytics
lib/eventgate.js
EventStatus
type
/** * Represents an EventGate process status result. * Each event passed to EventGate process() will map * to an final EventStatus. If the status is a failure * this.context should contain the Error. */ class EventStatus { /** * @param {string} status One of EventStatus.STATUSES. * @param {Object} c...
1,671
13493f58ec9ccf721ed0e66605a27951
swh:1:cnt:dc4be6aee50ae906c02e45eb9efccbaa5c8a8689;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=80-281/
79d5af07d1c27699523a169eee1d6c095b700773
eventgate
analytics
lib/eventgate.js
EventGate
type
/** * An EventGate asynchronously validates and produces a list of events. * The validate function and produce function implementations are passed * in by the user. It is expected that validate return a Promise of * the validated event or throws an ValidationError, and that produce returns a * Promise of a produc...
1,672
6541706947dd6a6f4f21eb9dc7419356
swh:1:cnt:dc4be6aee50ae906c02e45eb9efccbaa5c8a8689;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=18-32/
79d5af07d1c27699523a169eee1d6c095b700773
eventgate
analytics
lib/eventgate.js
EventStatus::constructor
function
/** * @param {string} status One of EventStatus.STATUSES. * @param {Object} context Event status context, possibly an Error. * @param {Object} event Event which this EventStatus represents status for. */ constructor(status, context, event) { // validate that status is a valid status ...
1,673
7e2f131dbb84e0d47de1efcb7b6e9a30
swh:1:cnt:dc4be6aee50ae906c02e45eb9efccbaa5c8a8689;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=212-280/
79d5af07d1c27699523a169eee1d6c095b700773
eventgate
analytics
lib/eventgate.js
EventGate::process
function
/** * Validates and produces events. * * @param {Array<Object>} events * @param {Object} context * Additional context to provide to validate() and produce() functions. * @return {Object<Array>} * of event validate/produce status keyed by status type. */ async proces...
1,674
cdfb6c1c415622ce4fec46a3355e1a34
swh:1:cnt:dc4be6aee50ae906c02e45eb9efccbaa5c8a8689;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=105-169/
79d5af07d1c27699523a169eee1d6c095b700773
eventgate
analytics
lib/eventgate.js
EventGate::constructor
function
// Define function params for JSDoc /** * @name EventGate~validate * @method * @param {Object} event * @param {Object} context * @return {Promise<Object>} */ /** * @name EventGate~produce * @method * @param {Object} event * @param {Object} context * @retur...
1,675
025e68dccf2673bcddd2505e531bc822
swh:1:cnt:dc4be6aee50ae906c02e45eb9efccbaa5c8a8689;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=34-59/
79d5af07d1c27699523a169eee1d6c095b700773
eventgate
analytics
lib/eventgate.js
EventStatus::toJSON
function
/** * Will be called if returned in an HTTP response body. * If this.context is an Error, it will be cleaned up * so that internal details are not potentially exposed. * * @return {Object} */ toJSON() { let context; if (this.context instanceof Error && !(this.context in...
1,676
f00826b9f3e702430e40bc758808be47
swh:1:cnt:dc4be6aee50ae906c02e45eb9efccbaa5c8a8689;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=171-210/
79d5af07d1c27699523a169eee1d6c095b700773
eventgate
analytics
lib/eventgate.js
EventGate::_processEvent
function
/** * Validates and produces event. * * @param {Object} event * @param {Object} context * @return {Promise<EventStatus>} */ async _processEvent(event, context = {}) { this.log.debug(`Validating ${this.eventRepr(event)}...`, { event }); try { // validate() wi...
1,677
db3a5a2ddb033d4e53693b1a4a49d06b
swh:1:cnt:ef47526048f28f9530be64a76389a4d5dd2d23d0;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=43-303/
a5a03bdf98eeca0e6743c50c40555915b95c950f
eventgate
analytics
lib/EventValidator.js
EventValidator
type
/** * Represents an event validator that uses schemas extracted from events using * extractSchemaUri. URIs extracted from events are then resolved with * resolveSchemaUri, and then JSON schemas at the resulting URL are downloaded. * Those schemas are used to create cached AJV validators. Note that * AJV will cac...
1,678
a5783508642ae178bbda22b83e98bc4f
swh:1:cnt:ef47526048f28f9530be64a76389a4d5dd2d23d0;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=55-155/
a5a03bdf98eeca0e6743c50c40555915b95c950f
eventgate
analytics
lib/EventValidator.js
EventValidator::constructor
function
/** * @name EventValidator~extractSchemaUri * @method * @param {Object} event * @return {string} */ /** * @name EventValidator~getSchema * @method * @param {string} schema_uri * @return {Promise<Object>} */ /** * @constructor * @param {Object} option...
1,679
9e647aa64ab72206ab7cb8e53c6d913a
swh:1:cnt:ef47526048f28f9530be64a76389a4d5dd2d23d0;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=214-223/
a5a03bdf98eeca0e6743c50c40555915b95c950f
eventgate
analytics
lib/EventValidator.js
EventValidator::schemaFor
function
/** * Returns a Promise of the schema for this event. * * @param {Object} event * @return {Promise<Object>} JSONSchema * @throws {EventSchemaLoadError} if the event schema URI fails loading. */ schemaFor(event) { return this.validatorFor(event).then((validator) => validator.sch...
1,680
251aeafdb1bb1cd7ee869504abe88355
swh:1:cnt:ef47526048f28f9530be64a76389a4d5dd2d23d0;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=270-281/
a5a03bdf98eeca0e6743c50c40555915b95c950f
eventgate
analytics
lib/EventValidator.js
EventValidator::validatorFor
function
/** * Returns a Promise of a validate function for the event. * The event's schema URI will be extracted using the provided extractSchemaUri function. * * @param {Object} event * @return {Promise<Function>} * @throws {EventSchemaLoadError} */ validatorFor(event) { // Extra...
1,681
5048f1115d2483997246b516cc603ffe
swh:1:cnt:ef47526048f28f9530be64a76389a4d5dd2d23d0;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=225-268/
a5a03bdf98eeca0e6743c50c40555915b95c950f
eventgate
analytics
lib/EventValidator.js
EventValidator::validatorAt
function
/** * Given a schema URI, this will load, compile, and cache the schema there. * If the schema URI or $id has been seen before, it will * be loaded from the AJV cache and not recompiled. * * @param {string} uri * @return {Promise<Function>} * @throws {EventSchemaLoadError} */ ...
1,682
c10165b8a20c2d1bae66c6dd0875c116
swh:1:cnt:ef47526048f28f9530be64a76389a4d5dd2d23d0;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=157-212/
a5a03bdf98eeca0e6743c50c40555915b95c950f
eventgate
analytics
lib/EventValidator.js
EventValidator::loadSchema
function
/** * This function is used as the ajv loadSchema option. It is * also used by validatorFor to load a schema * from an event's configured schema_uri_field (default '$schema'). * * We need to be able to handle both relative event schema URIs * (which should be prepended with the schema_bas...
1,683
4e0c4698f1333362f36eda85a4337c08
swh:1:cnt:ef47526048f28f9530be64a76389a4d5dd2d23d0;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=283-302/
a5a03bdf98eeca0e6743c50c40555915b95c950f
eventgate
analytics
lib/EventValidator.js
EventValidator::validate
function
/** * Returns a Promise of the validated event using it's JSONSchema at its schema URL, * Or throws an ValidationError. * * @param {Object} event * @return {Promise<Object>} event (with defaults filled in by AJV validator). * @throws {ValidationError} */ validate(event) { ...
1,684
33f797d203e1a32f991b50b40d554863
swh:1:cnt:b4dbbf9391eedf6371baab7e472b883e9d7ecda6;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=13-99/
0a837de1c3a782c4c5dc07d09f613b33e2402d93
eventgate
analytics
lib/swagger-ui.js
processRequest
function
function processRequest(app, req, res) { const reqPath = req.query.path || '/index.html'; const filePath = path.join(docRoot, reqPath); // Disallow relative paths. // Test relies on docRoot ending on a slash. if (filePath.slice(0, Math.max(0, docRoot.length)) !== docRoot) { throw new HTTPError({ status: 404...
1,685
c518695c5eb2f0ee1a46639520a18134
swh:1:cnt:47f9afd4ec7962d705696ded3beae84b504c0cf3;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=6-33/
362a31dc3212b4704de4824bea2cfe9d5fc22b85
eventgate
analytics
lib/util.js
HTTPError
type
/** * Error instance wrapping HTTP error responses */ class HTTPError extends Error { constructor(response) { super(); Error.captureStackTrace(this, HTTPError); if (response.constructor !== Object) { // just assume this is just the error message response = { status: 500, type: 'internal_error',...
1,686
f99a7f4389ad0ee8a2f74dbac5731098
swh:1:cnt:47f9afd4ec7962d705696ded3beae84b504c0cf3;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=11-32/
362a31dc3212b4704de4824bea2cfe9d5fc22b85
eventgate
analytics
lib/util.js
HTTPError::constructor
function
constructor(response) { super(); Error.captureStackTrace(this, HTTPError); if (response.constructor !== Object) { // just assume this is just the error message response = { status: 500, type: 'internal_error', title: 'InternalError', detail: response }; } this.name = this.constructo...
1,687
deb34e3ddf19790f81aed8580de5a21e
swh:1:cnt:47f9afd4ec7962d705696ded3beae84b504c0cf3;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=35-83/
362a31dc3212b4704de4824bea2cfe9d5fc22b85
eventgate
analytics
lib/util.js
reqForLog
function
/** * Generates an object suitable for logging out of a request object * * @param {!Request} req the request * @param {?RegExp} whitelistRE the RegExp used to filter headers * @return {!Object} an object containing the key components of the request */ function reqForLog(req, whitelistRE) { const ret ...
1,688
d968ff55910ba9d16d88b71aba410e0f
swh:1:cnt:47f9afd4ec7962d705696ded3beae84b504c0cf3;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=85-107/
362a31dc3212b4704de4824bea2cfe9d5fc22b85
eventgate
analytics
lib/util.js
errForLog
function
/** * Serialises an error object in a form suitable for logging. * * @param {!Error} err error to serialise * @return {!Object} the ecs formatted serialised version of the error */ function errForLog(err) { const ret = { message: err.message, error: { type: err.type, sta...
1,689
686812b31c2531e3e00d09707c81f539
swh:1:cnt:47f9afd4ec7962d705696ded3beae84b504c0cf3;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=188-206/
362a31dc3212b4704de4824bea2cfe9d5fc22b85
eventgate
analytics
lib/util.js
createRouter
function
/** * Creates a new router with some default options. * * @param {?Object} [opts] additional options to pass to express.Router() * @return {!Router} a new router object */ function createRouter(opts) { const options = { mergeParams: true }; if (opts && opts.constructor === Object) { Object.assign(options,...
1,690
0584784c2baba595218d8cdc2224d25c
swh:1:cnt:47f9afd4ec7962d705696ded3beae84b504c0cf3;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=109-186/
362a31dc3212b4704de4824bea2cfe9d5fc22b85
eventgate
analytics
lib/util.js
setErrorHandler
function
/** * Generates an error handler for the given applications and installs it. * * @param {!Application} app the application object to add the handler to */ function setErrorHandler(app) { app.use((err, req, res, next) => { let errObj; // ensure this is an HTTPError object if (err.constructor === HTTPError) {...
1,691
ab4a13daa72012a2b3e46e1b6c3420e6
swh:1:cnt:47f9afd4ec7962d705696ded3beae84b504c0cf3;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=208-264/
362a31dc3212b4704de4824bea2cfe9d5fc22b85
eventgate
analytics
lib/util.js
initAndLogRequest
function
/** * Adds logger to the request and logs it. * * @param {!*} req request object * @param {!Application} app application object */ function initAndLogRequest(req, app) { req.headers = req.headers || {}; req.headers['x-request-id'] = req.headers['x-request-id'] || uuidv1(); req.logger = app.logger.child( re...
1,692
1b9cbf4c0bdf141d0361e5fc5458b507
swh:1:cnt:e2ae055c0752534161c71bde462824985678d7ac;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=92-108/
7b632f2d049401a470ad58eca37dd03337dd7552
eventgate
analytics
lib/factories/default-eventgate.js
makeExtractSchemaUri
function
/** * Returns a function that extracts the event's schema URI. * * @param {Object} options * @param {string|Array<string>} options.schema_uri_field * Field(s) used to extract the schema_uri from an event. * If this is an array, the event will be searched for a field * named by each element. The fi...
1,693
290060974b03c304f8ee689dfe14324e
swh:1:cnt:e2ae055c0752534161c71bde462824985678d7ac;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=191-220/
7b632f2d049401a470ad58eca37dd03337dd7552
eventgate
analytics
lib/factories/default-eventgate.js
makeFileProduce
function
/** * Creates a function that writes events to output_path. * * @param {Object} options * @param {Object} options.output_path * @param {Object} logger * @param {Object} metrics * @return {EventGate~produce} (event, context) => Promise<event> */ function makeFileProduce(options, logger, metrics) { const fs =...
1,694
ef29993b566b047d1fb916239777c409
swh:1:cnt:e2ae055c0752534161c71bde462824985678d7ac;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=154-189/
7b632f2d049401a470ad58eca37dd03337dd7552
eventgate
analytics
lib/factories/default-eventgate.js
makeValidate
function
/** * Creates a new schema URI based validate(event) function. * * @param {Object} options * @param {string} options.schema_uri_field * Used to extract the event's schema URI. * @param {string} options.schema_base_uri * If set, this is prefixed to un-anchored schema URIs. * @param {string} options.sch...
1,695
dd6747987f2b7c9b5f2dd505f2ce08af
swh:1:cnt:e2ae055c0752534161c71bde462824985678d7ac;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=169-178/
7b632f2d049401a470ad58eca37dd03337dd7552
eventgate
analytics
lib/factories/default-eventgate.js
makeValidate::getSchema
function
/** * Searches options.schema_base_uris/uri for schema content, and returns * the first one found. * * @param {string} uri * @return {EventValidator~getSchema} */ function getSchema(uri) { return uriGetFirstObject(uri, options.schema_base_uris, options.schema_file_extension); ...
1,696
b24c24dfc0615b871af3ad0e88ca2d7b
swh:1:cnt:e2ae055c0752534161c71bde462824985678d7ac;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=110-152/
7b632f2d049401a470ad58eca37dd03337dd7552
eventgate
analytics
lib/factories/default-eventgate.js
makeExtractStream
function
/** * If options.stream_field is configured, then it will be used to extract * the event's destination stream name. Otherwise, it is assumed * that the event's sanitized schema URI should be used as the stream name. * The schema URI returned by the function returned by makeExtractSchemaUri * with options.schema_u...
1,697
d8b59465d0e1da106229b341a4f41d84
swh:1:cnt:e2ae055c0752534161c71bde462824985678d7ac;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=222-265/
7b632f2d049401a470ad58eca37dd03337dd7552
eventgate
analytics
lib/factories/default-eventgate.js
makeKafkaProduce
function
/** * Creates a function that returns function that produces events to Kafka. * NOTE: This function uses undefined Kafka key and partition when producing. * If you need to set key and/or partition, you should make your own produce function. * * @param {Object} options * @param {string} options.stream_field * ...
1,698
a94047753cb98751c8354dc923211f4f
swh:1:cnt:e2ae055c0752534161c71bde462824985678d7ac;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=267-317/
7b632f2d049401a470ad58eca37dd03337dd7552
eventgate
analytics
lib/factories/default-eventgate.js
makeProduce
function
/** * Creates a function that will write events to an output file and/or * produce events to Kafka. * * @param {Object} options * @param {string} options.stream_field * Used to construct the kafka topic * @param {string} options.schema_uri_field * Used to construct the kafka topic if stream_field is n...
1,699
921928999f868ed22ec0e0ce38366606
swh:1:cnt:e2ae055c0752534161c71bde462824985678d7ac;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventgate.git;lines=319-355/
7b632f2d049401a470ad58eca37dd03337dd7552
eventgate
analytics
lib/factories/default-eventgate.js
eventGateFactory
function
/** * Returns a Promise of an instantiated EventGate that uses EventValidator * and event schema URL lookup and Kafka to produce messages. This * instance does not do any producing of error events. * * @param {Object} options * @param {string} options.schema_uri_field * Used to extract the event's schema U...