Skip to content

Commit

Permalink
[MINOR]: Include Default Public Root Creation
Browse files Browse the repository at this point in the history
  • Loading branch information
amadolid committed Nov 29, 2024
1 parent 68c4df1 commit 16dea9f
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions jac-cloud/jac_cloud/plugin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from os import getenv
from os.path import split
from pickle import load
from typing import Any

from jaclang import jac_import
from jaclang.cli.cmdreg import cmd_registry
Expand All @@ -14,7 +15,7 @@
from pymongo.errors import ConnectionFailure, OperationFailure

from ..core.architype import BulkWrite, NodeAnchor
from ..core.context import SUPER_ROOT_ID
from ..core.context import PUBLIC_ROOT_ID, SUPER_ROOT_ID
from ..jaseci.datasources import Collection
from ..jaseci.models import User as BaseUser
from ..jaseci.utils import logger
Expand Down Expand Up @@ -138,21 +139,29 @@ def create_system_admin(
max_retry = BulkWrite.SESSION_MAX_TRANSACTION_RETRY
while retry <= max_retry:
try:
default_data: dict[str, Any] = {
"name": None,
"root": None,
"access": {
"all": "NO_ACCESS",
"roots": {"anchors": {}},
},
"architype": {},
"edges": [],
}

if not NodeAnchor.Collection.find_by_id(
PUBLIC_ROOT_ID, session=session
):
NodeAnchor.Collection.insert_one(
{"_id": PUBLIC_ROOT_ID, **default_data},
session=session,
)
if not NodeAnchor.Collection.find_by_id(
SUPER_ROOT_ID, session=session
):
NodeAnchor.Collection.insert_one(
{
"_id": SUPER_ROOT_ID,
"name": None,
"root": None,
"access": {
"all": "NO_ACCESS",
"roots": {"anchors": {}},
},
"architype": {},
"edges": [],
},
{"_id": SUPER_ROOT_ID, **default_data},
session=session,
)
if id := (
Expand Down

0 comments on commit 16dea9f

Please sign in to comment.