Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pydantic integration 2.4.1 #139

Merged
merged 34 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1001177
used new models
Mograbi Jun 6, 2023
a01670b
removed logs, added TODO
Mograbi Jun 8, 2023
5b73092
moved cache into BaseModel builtin
Mograbi Jun 13, 2023
9f68628
used Configuration.
Mograbi Jun 20, 2023
edce394
using the new flow pydantic
Mograbi Jul 2, 2023
c0303a0
Merge branch 'dev' of github.com:MOV-AI/backend into pydantic
Mograbi Jul 9, 2023
40fee80
used pydantic instead of MovaiBaseModel
Mograbi Jul 13, 2023
304ae59
Branch was auto-updated.
OttoMation-Movai Jul 13, 2023
c0ef840
used new models
Mograbi Jun 6, 2023
3757747
removed logs, added TODO
Mograbi Jun 8, 2023
15a2f1a
moved cache into BaseModel builtin
Mograbi Jun 13, 2023
211f064
used Configuration.
Mograbi Jun 20, 2023
b0be42a
using the new flow pydantic
Mograbi Jul 2, 2023
409af57
used pydantic instead of MovaiBaseModel
Mograbi Jul 13, 2023
2b9f695
rebase on dev
Mograbi Oct 23, 2023
c6f8f4d
pydantic V2 changes
Mograbi Oct 24, 2023
f238533
pydantic V2 fixes
Mograbi Oct 24, 2023
f6239b2
fixed error issue when creating scope
Mograbi Oct 26, 2023
35181f3
Branch was auto-updated.
OttoMation-Movai Oct 26, 2023
7551dad
update imports
Mograbi Oct 26, 2023
072da88
circular import errors, added role
Mograbi Nov 1, 2023
d7fab05
Package fixes
Mograbi Nov 1, 2023
cc6f839
Merge branch 'dev' into pydantic
erezz-mov-ai Nov 6, 2023
9590aa1
replace select with find
erezz-mov-ai Nov 29, 2023
55460cd
Merge branch 'dev' into pydantic
erezz-mov-ai Nov 29, 2023
3446759
Merge branch 'dev' into pydantic
erezz-mov-ai Dec 4, 2023
990c006
replace find with get_all
erezz-mov-ai Dec 10, 2023
592bfd1
Merge branch 'dev' into pydantic
erezz-mov-ai Dec 10, 2023
8fbfed5
update function name
erezz-mov-ai Dec 10, 2023
dc3c93b
import objects from new_models
erezz-mov-ai Dec 10, 2023
980fb34
revert back to Package from scopes
erezz-mov-ai Dec 27, 2023
2dbf5be
code review fixes, revert to scopes annotation and role
erezz-mov-ai Jan 3, 2024
7d087e3
fix sonarcloud issues
erezz-mov-ai Jan 4, 2024
d639e3d
update setup.py to latest package of shared, dal and gd-node
erezz-mov-ai Jan 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/core/permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _init_structure(cls, roles: List[str] = []) -> None:
roles = Role.list_roles_names()
for role_name in roles:
try:
role_obj = scopes.from_path(role_name, scope="Role")
role_obj = Role(role_name)
for (resource_key, permissions) in role_obj.Resources.items():
for permission in permissions:
if permission:
Expand Down
5 changes: 3 additions & 2 deletions backend/endpoints/api/v1/frontend/fleetmanager/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
from movai_core_shared.logger import Log

from dal.models.var import Var
from dal.scopes.robot import Robot
from dal.scopes.configuration import Configuration
from dal.new_models.configuration import Configuration
from dal.scopes.fleetrobot import FleetRobot
from dal.scopes.robot import Robot


LOGGER = Log.get_logger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions backend/endpoints/api/v1/frontend/ide/callbackeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Unauthorized copying of this file, via any medium is strictly prohibited
Proprietary and confidential
"""
from dal.models.callback import Callback
from dal.models.message import Message
from dal.new_models.callback import Callback
from dal.new_models.message import Message


class CallbcakEditor:
Expand Down
7 changes: 3 additions & 4 deletions backend/endpoints/api/v1/frontend/ide/datavalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from movai_core_shared.logger import Log

from dal.models.scopestree import ScopesTree
from dal.new_models.configuration import Configuration


LOGGER = Log.get_logger(__name__)
Expand All @@ -32,7 +32,7 @@ def validate_configuration(config_string):
config_key_path = config_string.replace("$(config ", "").replace(")", "").split(".")
config_name = config_key_path[0]
config_key_path.pop(0)
config = ScopesTree()().Configuration[config_name]
config = Configuration(config_name)
val = config.get_value()
for key in config_key_path:
val = val[key]
Expand All @@ -53,8 +53,7 @@ def validate_configuration_raw(value):
config_key_path = value.split(".")
config_name = config_key_path[0]
config_key_path.pop(0)
scopes = ScopesTree()
config = scopes().Configuration[config_name]
config = Configuration(config_name)
val = config.get_value()
for key in config_key_path:
val = val[key]
Expand Down
2 changes: 1 addition & 1 deletion backend/endpoints/api/v1/frontend/ide/getportsdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Unauthorized copying of this file, via any medium is strictly prohibited
Proprietary and confidential
"""
from dal.models.message import Message
from dal.new_models.message import Message


def get_ports_data():
Expand Down
47 changes: 24 additions & 23 deletions backend/endpoints/api/v1/frontend/ide/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@

from movai_core_shared.logger import Log

from dal.models.scopestree import ScopesTree
from dal.models.var import Var as Variable

from dal.scopes.fleetrobot import FleetRobot
from dal.scopes.package import Package


LOGGER = Log.get_logger(__name__)

try:
from movai_core_enterprise.scopes.graphicscene import GraphicScene
from movai_core_enterprise.models.annotation import Annotation
from movai_core_enterprise.models.graphicscene import GraphicScene as GraphicSceneModel
from movai_core_enterprise.scopes.graphicscene import GraphicScene as GraphicSceneScope
except ImportError:
LOGGER.warning("Failed to import GraphicScene, because movai_core_enterprise is not installed.")

Expand Down Expand Up @@ -257,9 +260,9 @@ def add2scene_aux(tree_node, scene_name, tree_object, scene):


def add2scene(tree_node, scene_name, tree_object):
scene_scope = ScopesTree().from_path(scene_name, scope="GraphicScene")
add2scene_aux(tree_node, scene_name, tree_object, scene_scope)
scene_scope.write()
scene = GraphicSceneModel(scene_name)
erezz-mov-ai marked this conversation as resolved.
Show resolved Hide resolved
add2scene_aux(tree_node, scene_name, tree_object, scene)
scene.write()


def add_annotation_to_object(
Expand Down Expand Up @@ -309,13 +312,13 @@ def del2scene_aux(obj_name, scene_name, scene_scope):


def del2scene(obj_name, scene_name):
scene_scope = ScopesTree().from_path(scene_name, scope="GraphicScene")
del2scene_aux(obj_name, scene_name, scene_scope)
scene_scope.write()
scene = GraphicSceneModel(scene_name)
del2scene_aux(obj_name, scene_name, scene)
scene.write()


def reset_scene(scene_path):
scene = ScopesTree().from_path(scene_path, scope="GraphicScene")
def reset_scene(scene_name):
scene = GraphicSceneModel(scene_name)
erezz-mov-ai marked this conversation as resolved.
Show resolved Hide resolved
types = list(filter(lambda x: x != "memory", list(scene.AssetType)))
for asset_type in types:
del scene.AssetType[asset_type]
Expand Down Expand Up @@ -345,7 +348,7 @@ def __init__(self, scene_name):
"""Virtually private constructor."""
MemorySingleton.__instance = self
self.scene_name = scene_name
self.memory = GraphicScene(scene_name).AssetType["memory"]
self.memory = GraphicSceneScope(scene_name).AssetType["memory"]

def __set_tree(self, tree=[]):
self.memory.add("AssetName", "tree", Value=tree)
Expand Down Expand Up @@ -479,11 +482,10 @@ def delete_add_object():
delete_add_object()

@classmethod
def on_retrieve_scene(cls, scene_path=DEFAULT_SCENE_NAME):
cls.migrate_poses_in_scene(scene_path)
my_scopes = ScopesTree()
scene = my_scopes.from_path(scene_path, scope="GraphicScene")
sprint("Scene types", scene_path, list(scene.AssetType))
def on_retrieve_scene(cls, scene_name=DEFAULT_SCENE_NAME):
cls.migrate_poses_in_scene(scene_name)
scene = GraphicSceneModel(scene_name)
erezz-mov-ai marked this conversation as resolved.
Show resolved Hide resolved
sprint("Scene types", scene_name, list(scene.AssetType))
return scene.AssetType["memory"].AssetName["tree"].Value.value

@staticmethod
Expand Down Expand Up @@ -513,16 +515,15 @@ def migrate_poses_in_scene(scene_path):
try:
types = ["KeyPoint", "Map", "Mesh", "GlobalRef", "Robot", "PointCloud", "NodeItem"]
scene_name = scene_path.split("/")[-1]
scopes = ScopesTree()
new_scene = scopes().GraphicScene[scene_name]
scene = GraphicScene(scene_name)
scene_model = GraphicSceneModel(scene_name)
scene_scope = GraphicSceneScope(scene_name)
for t in types:
try:
for i in new_scene.AssetType[t].AssetName:
point = new_scene.AssetType[t].AssetName[i].Value
for i in scene_model.AssetType[t].AssetName:
point = scene_model.AssetType[t].AssetName[i].Value
sprint("Migrate value", t, i)
if isinstance(point._value, Pose):
scene.AssetType[t].AssetName[i].Value = point.value
scene_scope.AssetType[t].AssetName[i].Value = point.value
except Exception as e:
sprint("Caught exception while migrating types...", e)
except Exception as e:
Expand All @@ -537,7 +538,7 @@ def get_computed_annotations(annotations_name):
computed_annotations_dict = {}
for annotation_name in annotations_name:
try:
annotation = ScopesTree().from_path(annotation_name, scope="Annotation")
annotation = Annotation(annotation_name)
computed_annotations_dict.update(annotation.get_computed_annotation())
except Exception as e:
sprint("Caught Exception while computing annotation", annotation_name, e)
Expand Down
Loading
Loading