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

BP-1156 - movai-cli frontend command is failing #182

Merged
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.5.0-10
current_version = 2.5.0-12
commit = True
message =
[skip actions] Automatic version bump {current_version} -> {new_version}
Expand Down
2 changes: 1 addition & 1 deletion backend/endpoints/api/v1/frontend/ide/flowtopbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def send_to_robot(msg):
return True

@staticmethod
def command_node(msg):
def command_node(**msg):
if msg["robotName"] == "Default":
robot = Robot
else:
Expand Down
7 changes: 4 additions & 3 deletions backend/endpoints/api/v1/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
from dal.models.role import Role
from dal.models.var import Var
from dal.movaidb import MovaiDB
from dal.new_models.application import Application

from dal.new_models.callback import Callback
from dal.new_models.configuration import Configuration
from dal.new_models.node import Node
from dal.new_models.flow import Flow
from dal.new_models.message import Message
from dal.new_models.ports import Ports

from dal.scopes.application import Application
from dal.scopes.form import Form
from dal.scopes.package import Package
from dal.scopes.robot import Robot
Expand Down Expand Up @@ -342,7 +343,7 @@ def spa_parse_template(self, application: Application, html, request):
serverdata.update(self.get_spa_configuration(application))
# get application meta-data
serverdata.update(
{"Application": application.model_dump()["Application"][application.name]}
{"Application": application.get_dict()["Application"][application.name]}
)
except Exception as error:
LOGGER.error(str(error))
Expand Down Expand Up @@ -664,7 +665,7 @@ def create_application_format(url, label, icon, enable, app_type):
permissions = NewACLManager.get_permissions()["Applications"]
output = {"success": True, "result": []}

apps: List[Application] = Application.get_all_models()
apps: List[Application] = Application.get_model_objects()
for app in apps:
url = app.Package if app.Type == "application" else app.EntryPoint
label = app.Label
Expand Down
95 changes: 49 additions & 46 deletions backend/tools/deploy_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import argparse
import json
import os
from dal.new_models import Application

from dal.scopes.application import Application

JSON_FILE = "package.json"

Expand All @@ -38,6 +39,53 @@ def get_json(root, key=None):
return result


def deploy(args):
_file = os.path.join(args.path, args.file)
if not os.path.exists(_file):
raise AppException(f"Could not find file {args.file} in {args.path}")

print("Reading file:", _file)

with open(_file) as fjson:
_json = json.load(fjson)
app_json = get_json(_json, args.key)

if not app_json.get("generateMetadata", False):
# don't generate metadata
return

app = None

try:
app = Application(app_json["name"])
print(f"Updating application {app.name}")
except Exception:
app = Application(app_json["name"], new=True)
print(f"Creating application {app.name}")

print("-" * 100)

keys_to_skipe = ["name", "generateMetadata"]

for key, value in app_json.items():

if key in keys_to_skipe:
continue

if isinstance(value, dict):
app_dict = getattr(app, key)
app_dict.update(value)
print(f"Setting key: {key} \nWith value:\n {value}")
continue

try:
setattr(app, key, value)
print(f"Setting key: {key} \nWith value:\n {value}")

except AttributeError:
print(f"Attribute {key} does not exist")


def main():
"""Create application based on package.json data"""

Expand Down Expand Up @@ -68,50 +116,5 @@ def main():
exit(1)


def deploy(args):
_file = os.path.join(args.path, args.file)
if not os.path.exists(_file):
raise AppException(f"Could not find file {args.file} in {args.path}")

print("Reading file:", _file)

with open(_file) as fjson:

_json = json.load(fjson)

app_json = get_json(_json, args.key)

if not app_json.get("generateMetadata", False):
# don't generate metadata
return

app = Application.model_validate(app_json["name"])
print(f"Updating application {app.name}")

print(f"-" * 100)

keys_to_skipe = ["name", "generateMetadata"]

for key, value in app_json.items():

if key in keys_to_skipe:
continue

if isinstance(value, dict):
app_dict = getattr(app, key)
app_dict.update(value)
print(f"Setting key: {key} \nWith value:\n {value}")
continue

try:
setattr(app, key, value)
print(f"Setting key: {key} \nWith value:\n {value}")

except AttributeError:
print(f"Attribute {key} does not exist")

app.save()


if __name__ == "__main__":
main()
17 changes: 11 additions & 6 deletions backend/tools/upload_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
import zipfile

from movai_core_shared.logger import Log
from movai_core_shared.exceptions import DoesNotExist

from dal.scopes import Package
from dal.scopes.package import Package

sys.path.append(os.path.abspath(".."))

Expand Down Expand Up @@ -46,14 +47,18 @@ def main(build_folder: str, package_name: str):

getFolderStructure(build_folder, build_files)

pkg = Package(package_name)
pkg.delete()
logger.info("Update Package '%s'" % package_name)
try:
pkg = Package(package_name)
pkg.remove()
del pkg
logger.info("Overwritting Package '%s'" % package_name)
except DoesNotExist:
logger.info("Creating Package '%s'" % package_name)

pkg = Package(package_name, new=True)
for x in build_files:
pkg.add_file(x, build_files[x])
pkg.add("File", x, Value=build_files[x])
logger.info("File '%s' added to package '%s'" % (x, package_name))
pkg.save()


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

setuptools.setup(
name="backend",
version="2.5.0-10",
version="2.5.0-12",
author="Backend team",
author_email="[email protected]",
description="Movai Backend Package",
Expand Down
Loading