Commit fa10e4e2 authored by Daniele Venzano's avatar Daniele Venzano

Restore python script to build json with correct image version

parent ad48bdf8
Pipeline #4819 passed with stages
in 22 minutes and 10 seconds
......@@ -17,6 +17,15 @@ build:pytorch:
script:
- docker build -t ${REPOSITORY}/pytorch:${VERSION} docker/pytorch
build:json:
image: python:3-alpine
stage: build
script:
- python gen_json.py
artifacts:
paths:
- "*.json"
test:json:
image: python:3-alpine
stage: test
......
# Copyright (c) 2016, Daniele Venzano
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Jupyter Zoe application description generator."""
import json
import sys
import os
REPOSITORY = os.getenv("REPOSITORY", default="zapps")
VERSION = os.getenv("VERSION", default="latest")
UPSTREAM_NOTEBOOKS = [
("pytorch-notebook", REPOSITORY + "/pytorch:" + VERSION)
]
ZOE_APPLICATION_DESCRIPTION_VERSION = 3
options = {
'core_limit': {
'value': 4,
'description': 'Notebook core limit'
},
'memory_limit': {
'value': 4 * (1024**3),
'description': 'Notebook memory limit (bytes)'
}
}
def jupyter_service(memory_limit, core_limit, image):
"""
:rtype: dict
"""
service = {
'name': "jupyter",
'image': image,
'monitor': True,
'resources': {
"memory": {
"min": memory_limit,
"max": memory_limit
},
"cores": {
"min": core_limit,
"max": core_limit
}
},
'ports': [
{
'name': 'Jupyter Notebook interface',
'protocol': 'tcp',
'port_number': 8888,
'url_template': 'http://{ip_port}/'
}
],
'environment': [
['NB_UID', '1000'],
['HOME', '/mnt/workspace']
],
'volumes': [],
'command': None,
'work_dir': '/mnt/workspace',
'total_count': 1,
'essential_count': 1,
'replicas': 1,
'startup_order': 0
}
return service
if __name__ == '__main__':
for app_name, image in UPSTREAM_NOTEBOOKS:
app = {
'name': app_name,
'version': ZOE_APPLICATION_DESCRIPTION_VERSION,
'will_end': False,
'size': 512,
'services': [
jupyter_service(options["memory_limit"]["value"], options["core_limit"]["value"], image)
]
}
json.dump(app, open(app_name + ".json", "w"), sort_keys=True, indent=4)
print("ZApps written")
{
"name": "pytorch-notebook",
"services": [
{
"command": null,
"environment": [
[
"NB_UID",
"1000"
],
[
"HOME",
"/mnt/workspace"
]
],
"essential_count": 1,
"image": "zapps/pytorch:latest",
"monitor": true,
"name": "jupyter",
"ports": [
{
"name": "Jupyter Notebook interface",
"port_number": 8888,
"protocol": "tcp",
"url_template": "http://{ip_port}/"
}
],
"replicas": 1,
"resources": {
"cores": {
"max": 4,
"min": 4
},
"memory": {
"max": 4294967296,
"min": 4294967296
}
},
"startup_order": 0,
"total_count": 1,
"volumes": [],
"work_dir": "/mnt/workspace"
}
],
"size": 512,
"version": 3,
"will_end": false
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment