Skip to content

Commit

Permalink
Merge branch 'main' into setup/vendor-buildchain-with-asyncudp
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Jul 3, 2023
2 parents e813f41 + b016597 commit 14931dc
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 14 deletions.
6 changes: 5 additions & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ require:db-migration:
- any: ['src/ai/backend/manager/models/alembic/versions/*.py']

area:docs:
- any: ['docs/**/*']
- any: [
'docs/**/*',
'src/ai/backend/manager/api/**/*.py',
'src/ai/backend/manager/models/gql.py',
]

comp:storage-proxy:
- any: ['src/ai/backend/storage/**/*.py']
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ permissions:

jobs:
docs-preview-links-:
if: ${{ contains(github.event.pull_request.labels.*.name, 'docs') }}
if: ${{ contains(github.event.pull_request.labels.*.name, 'area:docs') }}
runs-on: ubuntu-latest
steps:
- uses: readthedocs/actions/preview@v1
- name: Make a link to the doc preview build (en)
uses: readthedocs/actions/preview@v1
with:
project-slug: "sorna"
- uses: readthedocs/actions/preview@v1
- name: Make a link to the doc preview build (ko)
uses: readthedocs/actions/preview@v1
with:
project-slug: "sorna-ko"
project-language: "ko"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ ENV/
/vfroot/
/*.pid
/scratches/
logs

# Additional clones for editable components
/src/ai/backend/webui/
Expand Down
4 changes: 4 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ build:
tools:
python: "3.11"
jobs:
post_checkout:
# Skip the build if there is no docs label
- scripts/check-docs-label.sh
pre_build:
# Auto-generate REST API reference
- PYTHONPATH="src" python -m ai.backend.manager.openapi docs/manager/rest-reference/openapi.json
python:
install:
Expand Down
1 change: 1 addition & 0 deletions changes/1358.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `groups_name` aggregated field in querying keypairs by email or access key to prevent field reference error.
6 changes: 6 additions & 0 deletions scripts/check-docs-label.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash
# This script is executed inside the RTD's build environment.
wget -qO ./jq https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64
chmod +x ./jq
[ "${READTHEDOCS_VERSION_TYPE}" != "external" ] && exit 0 # always continue on non-PR-preview builds
(curl -sL https://api.github.com/repos/lablup/backend.ai/issues/${READTHEDOCS_VERSION}/labels | ./jq -e '.[] | select(.name == "area:docs")' > /dev/null) && echo "continue to build docs for PR" || exit 183
46 changes: 36 additions & 10 deletions src/ai/backend/manager/models/keypair.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,27 @@ async def batch_load_by_email(
domain_name: str = None,
is_active: bool = None,
) -> Sequence[Sequence[Optional[KeyPair]]]:
from .group import association_groups_users, groups
from .user import users

j = sa.join(
keypairs,
users,
keypairs.c.user == users.c.uuid,
j = (
sa.join(keypairs, users, keypairs.c.user == users.c.uuid)
.join(association_groups_users, users.c.uuid == association_groups_users.c.user_id)
.join(groups, association_groups_users.c.group_id == groups.c.id)
)
query = (
sa.select(
[
keypairs,
users.c.email,
users.c.full_name,
agg_to_array(groups.c.name).label("groups_name"),
]
)
.select_from(j)
.where(keypairs.c.user_id.in_(user_ids))
.group_by(keypairs, users.c.email, users.c.full_name)
)
query = sa.select([keypairs]).select_from(j).where(keypairs.c.user_id.in_(user_ids))
if domain_name is not None:
query = query.where(users.c.domain_name == domain_name)
if is_active is not None:
Expand All @@ -438,14 +451,27 @@ async def batch_load_by_ak(
*,
domain_name: str = None,
) -> Sequence[Optional[KeyPair]]:
from .group import association_groups_users, groups
from .user import users

j = sa.join(
keypairs,
users,
keypairs.c.user == users.c.uuid,
j = (
sa.join(keypairs, users, keypairs.c.user == users.c.uuid)
.join(association_groups_users, users.c.uuid == association_groups_users.c.user_id)
.join(groups, association_groups_users.c.group_id == groups.c.id)
)
query = (
sa.select(
[
keypairs,
users.c.email,
users.c.full_name,
agg_to_array(groups.c.name).label("groups_name"),
]
)
.select_from(j)
.where(keypairs.c.access_key.in_(access_keys))
.group_by(keypairs, users.c.email, users.c.full_name)
)
query = sa.select([keypairs]).select_from(j).where(keypairs.c.access_key.in_(access_keys))
if domain_name is not None:
query = query.where(users.c.domain_name == domain_name)
async with graph_ctx.db.begin_readonly() as conn:
Expand Down

0 comments on commit 14931dc

Please sign in to comment.