lablup / lablup/backend.ai

Generalize scope membership queries over the member type

Open
#14,126 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
15h 13m
Merged PRs (30d)
368

Description

Replace user_scope_membership_query and user_scope_membership_exists (models/virtual_entity/queries.py) with member-type-generic forms: scope_membership_query(scope_type, member_type) returning (member_id, scope_id) pairs, and scope_membership_exists(scope_type, scope_id, member_type, member_id). The graph edge is (scope node, member node) and the member kind is a value, so a user-only helper is a special case; the optional user_id filter added in BA-7595 goes with it.

scope_membership_exists resolves both ends as scalar subqueries on virtual_entities (uq_virtual_entities_entity) and probes entity_memberships by primary key; no join and no alias. The pair query keeps two joins because both node ids are output columns. Callers narrowing to one member filter the subquery on member_id.

Call sites (about 30, all passing PROJECT_SCOPE_TYPE) gain USER_ENTITY_TYPE mechanically; the pair query's user_id column becomes member_id (gql_legacy user/keypair/group). Follow-up of BA-7595.

JIRA Issue: BA-7596

Contributor guide

Open the contributing guide

Research direction

Start in models/virtual_entity/queries.py by reading the existing user_scope_membership_query and user_scope_membership_exists helpers, then inspect the roughly 30 call sites. Update the helpers and callers to use member_type and member_id, preserving the scalar-subquery primary-key probe for the exists query and the two-join pair query; done means all PROJECT_SCOPE_TYPE callers pass USER_ENTITY_TYPE or the appropriate member type.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.