示例#1
0
def calculate_url(host: str,
                  url: str = None,
                  model_route: str = None,
                  model_deployment: str = None,
                  url_prefix: str = None,
                  mr_client: ModelRouteClient = None):
    """
    Calculate url for model

    :param host: edge host
    :param url: full url to model api
    :param model_route: model route name
    :param model_deployment: model deployment name
    :param url_prefix: model prefix
    :return: model url
    """
    if url:
        return url

    if url_prefix:
        LOGGER.debug('')
        return f'{host}{url_prefix}'

    model_route = model_route or model_deployment
    if model_route:
        if mr_client is None:
            mr_client = ModelRouteClient()

        model_route = mr_client.get(model_route)

        LOGGER.debug('Found model route: %s', model_route)
        return model_route.status.edge_url

    raise NotImplementedError("Cannot create a model url")
示例#2
0
 def route_delete(route_id: str):
     return ModelRouteClient().delete(route_id)
示例#3
0
 def route_post(payload_file):
     api_object = parse_resources_file_with_one_item(payload_file).resource
     return ModelRouteClient().create(api_object)
示例#4
0
 def route_get_id(route_id: str):
     return ModelRouteClient().get(route_id)
示例#5
0
 def route_get():
     return ModelRouteClient().get_all()
示例#6
0
def route(ctx: click.core.Context, url: str, token: str):
    """
    Allow you to perform actions on routes
    """
    ctx.obj = ModelRouteClient(url, token)
示例#7
0
    PackagingIntegration(
        id=ENTITY_ID,
        spec=PackagingIntegrationSpec(default_image="odahu:image",
                                      entrypoint="some_entrypoint"),
    ),
    packaging_integration.packaging_integration,
    'PackagingIntegration',
)

DEPLOYMENT = EntityTestData(
    ModelDeploymentClient(),
    ModelDeployment(id=ENTITY_ID,
                    spec=ModelDeploymentSpec(image="odahu:image",
                                             min_replicas=0),
                    status=ModelDeploymentStatus(
                        state=READY_STATE,
                        available_replicas=1,
                    )),
    deployment.deployment,
    'ModelDeployment',
)

ROUTER = EntityTestData(
    ModelRouteClient(),
    ModelRoute(id=ENTITY_ID,
               spec=ModelRouteSpec(mirror="test", ),
               status=ModelRouteStatus(state=READY_STATE, )),
    route.route,
    'ModelRoute',
)