Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restore director schemas
Browse files Browse the repository at this point in the history
pcrespov committed Nov 21, 2024
1 parent 0775605 commit 8010bf9
Showing 11 changed files with 4,625 additions and 0 deletions.
492 changes: 492 additions & 0 deletions api/specs/director/openapi.yaml

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions api/specs/director/schemas/error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
components:
schemas:
ErrorEnveloped:
type: object
required:
- error
properties:
data:
nullable: true
default: null
error:
$ref: '#/components/schemas/ErrorType'

ErrorType:
type: object
required:
- status
- message
properties:
message:
description: Error message
type: string
example: Unexpected error
errors:
type: array
items:
properties:
code:
type: string
description: Server Exception
example: ServiceUUIDNotFoundError
status:
description: Error code
type: integer
example: 404
28 changes: 28 additions & 0 deletions api/specs/director/schemas/health_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
components:
schemas:
HealthCheckEnveloped:
type: object
required:
- data
properties:
data:
$ref: '#/components/schemas/HealthCheckType'
error:
nullable: true
default: null

HealthCheckType:
type: object
properties:
name:
type: string
example: director service
status:
type: string
example: SERVICE_RUNNING
api_version:
type: string
example: 1.0.0-dev
version:
type: string
example: 1dfcfdc

Large diffs are not rendered by default.

2,419 changes: 2,419 additions & 0 deletions api/specs/director/schemas/node-meta-v0.0.1-pydantic.json

Large diffs are not rendered by default.

488 changes: 488 additions & 0 deletions api/specs/director/schemas/node-meta-v0.0.1.json

Large diffs are not rendered by default.

112 changes: 112 additions & 0 deletions api/specs/director/schemas/running_service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
components:
schemas:
RunningServicesEnveloped:
type: object
required:
- data
properties:
data:
$ref: "#/components/schemas/RunningServicesArray"
error:
nullable: true
default: null

RunningServicesArray:
type: array
items:
$ref: "#/components/schemas/RunningServiceType"

RunningServiceEnveloped:
type: object
required:
- data
properties:
data:
$ref: "#/components/schemas/RunningServiceType"
error:
nullable: true
default: null

RunningServiceType:
type: object
required:
- published_port
- service_uuid
- service_key
- service_version
- service_host
- service_port
- service_state
- user_id
properties:
published_port:
description: The ports where the service provides its interface
type: integer
format: int32
minimum: 1
example: 30000
entry_point:
description: The entry point where the service provides its interface if specified
type: string
example: /the/entry/point/is/here
service_uuid:
description: The UUID attached to this service
type: string
# format: UUID
example: 123e4567-e89b-12d3-a456-426655440000
service_key:
type: string
description: distinctive name for the node based on the docker registry path
pattern: '^(simcore)/(services)/(comp|dynamic)(/[\w/-]+)+$'
example:
- simcore/services/comp/itis/sleeper
- simcore/services/dynamic/3dviewer
service_version:
type: string
description: semantic version number
pattern: >-
^(0|[1-9]\d*)(\.(0|[1-9]\d*)){2}(-(0|[1-9]\d*|\d*[-a-zA-Z][-\da-zA-Z]*)(\.(0|[1-9]\d*|\d*[-a-zA-Z][-\da-zA-Z]*))*)?(\+[-\da-zA-Z]+(\.[-\da-zA-Z-]+)*)?$
example:
- 1.0.0
- 0.0.1
service_host:
description: service host name within the network
type: string
example: jupyter_E1O2E-LAH
service_port:
description: port to access the service within the network
type: integer
minimum: 1
example: 8081
service_basepath:
description: different base path where current service is mounted otherwise defaults to root
type: string
example: "/x/E1O2E-LAH"
default: ""
service_state:
description: >
the service state
* 'pending' - The service is waiting for resources to start
* 'pulling' - The service is being pulled from the registry
* 'starting' - The service is starting
* 'running' - The service is running
* 'complete' - The service completed
* 'failed' - The service failed to start
type: string
enum:
- pending
- pulling
- starting
- running
- complete
- failed
service_message:
description: >-
the service message
type: string
example: no suitable node (insufficient resources on 1 node)
user_id:
description: >-
the user that started the service
type: string
example: "123"
21 changes: 21 additions & 0 deletions api/specs/director/schemas/scripts/create_node-meta-schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments

import json
import sys
from pathlib import Path

import jsonref
from models_library.services import ServiceMetaDataPublished

CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent


if __name__ == "__main__":
with Path.open(CURRENT_DIR.parent / "node-meta-v0.0.1-pydantic.json", "w") as f:
schema = ServiceMetaDataPublished.schema_json()
schema_without_ref = jsonref.loads(schema)

json.dump(schema_without_ref, f, indent=2)
23 changes: 23 additions & 0 deletions api/specs/director/schemas/scripts/create_project-schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments

import json
import sys
from pathlib import Path

import jsonref
from models_library.projects import Project

CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent


if __name__ == "__main__":
with Path.open(
CURRENT_DIR.parent / "common/schemas/project-v0.0.1-pydantic.json", "w"
) as f:
schema = Project.schema_json()
schema_without_ref = jsonref.loads(schema)

json.dump(schema_without_ref, f, indent=2)
37 changes: 37 additions & 0 deletions api/specs/director/schemas/scripts/remove_definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import argparse
import logging
import sys
from pathlib import Path

import yaml

_logger = logging.getLogger(__name__)


CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
SCHEMAS_DIR = CURRENT_DIR.parent


if __name__ == "__main__":
parser = argparse.ArgumentParser(
"Remove Definitions",
description="prunes 'definitions' from json-schemas in 'source_file_name' and dumps it into 'target_file_name'",
)
parser.add_argument("source_file_name", type=str)
parser.add_argument("target_file_name", type=str)
args = parser.parse_args()

file_source_path: Path = SCHEMAS_DIR / args.source_file_name
file_target_path: Path = SCHEMAS_DIR / args.target_file_name

try:
data = yaml.safe_load(file_source_path.read_text())
data.pop("definitions", None)
with Path.open(file_target_path, "w") as file_stream:
yaml.safe_dump(data, file_stream)
except yaml.YAMLError:
_logger.exception(
"Ignoring error while load+pop+dump %s -> %s",
file_source_path,
file_target_path,
)
69 changes: 69 additions & 0 deletions api/specs/director/schemas/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
components:
schemas:
ServicesEnveloped:
type: object
required:
- data
properties:
data:
type: array
items:
$ref: "./node-meta-v0.0.1-pydantic-converted-clean.yaml"
error:
nullable: true
default: null

ServiceExtras:
type: object
required:
- node_requirements
properties:
node_requirements:
type: object
required:
- CPU
- RAM
properties:
CPU:
type: number
default: 1.0
minimum: 1.0
GPU:
type: integer
minimum: 0
RAM:
type: integer
format: int64
minimum: 1024
MPI:
type: integer
maximum: 1

service_build_details:
type: object
properties:
build_date:
type: string
vcs_ref:
type: string
vcs_url:
type: string

container_spec:
type: object
properties:
command:
type: array
items:
type: string

ServiceExtrasEnveloped:
type: object
required:
- data
properties:
data:
$ref: "#/components/schemas/ServiceExtras"
error:
nullable: true
default: null

0 comments on commit 8010bf9

Please sign in to comment.