Skip to content

Commit

Permalink
fix(apply): fixes the schema not found errors
Browse files Browse the repository at this point in the history
The recent change in JSON Schema validation made it such that the
Schemas are loaded at runtime. But, the Schemas were not being shipped
in the Python wheel. This was leading to schema not found error upon
running the apply command.

This commit adds schemas as part of the shipped Wheel to fix the issue.
  • Loading branch information
ankitrgadiya committed Apr 20, 2023
1 parent bbf65f2 commit d4847a5
Show file tree
Hide file tree
Showing 27 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Node artifact files
node_modules/
dist/
jsonschema/json/
riocli/jsonschema/schemas/json/
# Compiled Java class files
*.class

Expand Down
1 change: 1 addition & 0 deletions jsonschema
2 changes: 1 addition & 1 deletion riocli/build/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from rapyuta_io import Build as v1Build, Client, BuildOptions, CatkinOption

from riocli.model import Model
from riocli.utils.validate import validate_manifest, load_schema
from riocli.jsonschema.validate import validate_manifest, load_schema


class Build(Model):
Expand Down
2 changes: 1 addition & 1 deletion riocli/deployment/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from riocli.model import Model
from riocli.package.util import find_package_guid
from riocli.static_route.util import find_static_route_guid
from riocli.utils.validate import validate_manifest, load_schema
from riocli.jsonschema.validate import validate_manifest, load_schema


class Deployment(Model):
Expand Down
2 changes: 1 addition & 1 deletion riocli/device/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from rapyuta_io.clients.device import Device as v1Device, DevicePythonVersion

from riocli.model import Model
from riocli.utils.validate import validate_manifest, load_schema
from riocli.jsonschema.validate import validate_manifest, load_schema


class Device(Model):
Expand Down
2 changes: 1 addition & 1 deletion riocli/disk/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from riocli.disk.util import _api_call
from riocli.model import Model
from riocli.utils.validate import load_schema, validate_manifest
from riocli.jsonschema.validate import load_schema, validate_manifest


class Disk(Model):
Expand Down
Empty file added riocli/jsonschema/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion riocli/utils/validate.py → riocli/jsonschema/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def load_schema(resource: str) -> dict:
"""
Reads JSON schema yaml and returns a dict.
"""
schema_dir = Path('jsonschema')
schema_dir = Path(__file__).parent.joinpath('schemas')
with open(schema_dir.joinpath(resource + "-schema.yaml")) as f:
return yaml.safe_load(f)

Expand Down
2 changes: 1 addition & 1 deletion riocli/managedservice/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from riocli.managedservice.util import ManagedServicesClient
from riocli.model import Model
from riocli.utils.validate import load_schema, validate_manifest
from riocli.jsonschema.validate import load_schema, validate_manifest


class ManagedService(Model):
Expand Down
5 changes: 0 additions & 5 deletions riocli/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,17 @@
from abc import ABC, abstractmethod
from datetime import datetime
from shutil import get_terminal_size
import yaml
import os

import click
from munch import Munch, munchify
from rapyuta_io import Client
from pathlib import Path

from riocli.project.util import find_project_guid

prompt = ">> {}{}{} [{}]" # >> msg spacer rigth_msg time

DELETE_POLICY_LABEL = 'rapyuta.io/deletionPolicy'

schema_dir = Path('jsonschema')

def message_with_prompt(msg, right_msg="", fg='white', with_time=True):
columns, _ = get_terminal_size()
time = datetime.now().isoformat('T')
Expand Down
2 changes: 1 addition & 1 deletion riocli/network/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from riocli.model import Model
from riocli.network.util import find_network_name, NetworkNotFound
from riocli.utils.validate import validate_manifest, load_schema
from riocli.jsonschema.validate import validate_manifest, load_schema


class Network(Model):
Expand Down
2 changes: 1 addition & 1 deletion riocli/package/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from rapyuta_io.clients.package import RestartPolicy

from riocli.model import Model
from riocli.utils.validate import validate_manifest, load_schema
from riocli.jsonschema.validate import validate_manifest, load_schema


class Package(Model):
Expand Down
2 changes: 1 addition & 1 deletion riocli/project/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from rapyuta_io import Project as v1Project, Client

from riocli.model import Model
from riocli.utils.validate import validate_manifest, load_schema
from riocli.jsonschema.validate import validate_manifest, load_schema


class Project(Model):
Expand Down
2 changes: 1 addition & 1 deletion riocli/secret/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
SecretConfigSourceSSHAuth, Client

from riocli.model import Model
from riocli.utils.validate import load_schema, validate_manifest
from riocli.jsonschema.validate import load_schema, validate_manifest


class Secret(Model):
Expand Down
2 changes: 1 addition & 1 deletion riocli/static_route/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from rapyuta_io.clients.static_route import StaticRoute as v1StaticRoute

from riocli.model import Model
from riocli.utils.validate import validate_manifest, load_schema
from riocli.jsonschema.validate import validate_manifest, load_schema


class StaticRoute(Model):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
packages=find_packages(),
package_data={
'riocli': [
'apply/manifests/*.yaml'
'apply/manifests/*.yaml',
'jsonschema/schemas/*.yaml'
]
},
include_package_data=True,
Expand Down

0 comments on commit d4847a5

Please sign in to comment.