Skip to content

Commit

Permalink
[MINOR]: Remove JacFeature import inside method; fix FastAPI.enable t…
Browse files Browse the repository at this point in the history
…rigger
  • Loading branch information
amadolid committed Oct 2, 2024
1 parent 16c10db commit 1837dac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 1 addition & 3 deletions jac-cloud/jac_cloud/core/architype.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from bson import ObjectId

from jaclang.plugin.feature import JacFeature as Jac
from jaclang.runtimelib.architype import (
Access as _Access,
AccessLevel,
Expand Down Expand Up @@ -422,8 +423,6 @@ def build_query(
bulk_write: BulkWrite,
) -> None:
"""Save Anchor."""
from jaclang.plugin.feature import JacFeature as Jac

if self.state.deleted is False and Jac.check_write_access(self): # type: ignore[arg-type]
self.state.deleted = True
self.delete(bulk_write)
Expand Down Expand Up @@ -470,7 +469,6 @@ def update(self, bulk_write: BulkWrite, propagate: bool = False) -> None:
############################################################
# POPULATE CONTEXT #
############################################################
from jaclang.plugin.feature import JacFeature as Jac

if Jac.check_write_access(self): # type: ignore[arg-type]
set_architype = changes.pop("$set", {})
Expand Down
3 changes: 1 addition & 2 deletions jac-cloud/jac_cloud/core/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from bson import ObjectId

from jaclang.plugin.feature import JacFeature as Jac
from jaclang.runtimelib.memory import Memory


Expand Down Expand Up @@ -115,8 +116,6 @@ def close(self) -> None:

def get_bulk_write(self) -> BulkWrite:
"""Sync memory to database."""
from jaclang.plugin.feature import JacFeature as Jac

bulk_write = BulkWrite()

for anchor in self.__gc__:
Expand Down
4 changes: 2 additions & 2 deletions jac-cloud/jac_cloud/plugin/jaseci.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def get_edges(
target_obj: list[NodeArchitype] | None,
) -> list[EdgeArchitype]:
"""Get edges connected to this node."""
if FastAPI.enable():
if FastAPI.is_enabled():
JaseciContext.get().mem.populate_data(node.edges)

return JacFeatureImpl.get_edges(
Expand All @@ -407,7 +407,7 @@ def edges_to_nodes(
target_obj: list[NodeArchitype] | None,
) -> list[NodeArchitype]:
"""Get set of nodes connected to this node."""
if FastAPI.enable():
if FastAPI.is_enabled():
JaseciContext.get().mem.populate_data(node.edges)

return JacFeatureImpl.edges_to_nodes(
Expand Down

0 comments on commit 1837dac

Please sign in to comment.