Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
SUBMARINE-633. [SDK] Support run experiment with synced code
Browse files Browse the repository at this point in the history
### What is this PR for?
- Support sync code when submitting the experiment
- Update `OpenAPI.json`
- update example, https://github.com/apache/submarine/blob/master/submarine-sdk/pysubmarine/example/submarine_experiment_sdk.ipynb
- Update experiment integration tests

### What type of PR is it?
[Improvement]

### Todos
* [ ] - Task

### What is the Jira issue?
https://issues.apache.org/jira/browse/SUBMARINE-633

### How should this be tested?
https://travis-ci.org/github/pingsutw/hadoop-submarine/builds/730205378

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Kevin Su <pingsutw@gmail.com>

Closes #411 from pingsutw/SUBMARINE-633 and squashes the following commits:

02659c1 [Kevin Su] SUBMARINE-633. [SDK] Support run experiment with synced code
  • Loading branch information
pingsutw authored and xunliu committed Sep 29, 2020
1 parent 5934a71 commit b2d3eed
Show file tree
Hide file tree
Showing 9 changed files with 712 additions and 307 deletions.
52 changes: 49 additions & 3 deletions dev-support/pysubmarine/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,32 @@
}
}
},
"Environment" : {
"CodeSpec" : {
"type" : "object",
"properties" : {
"syncMode" : {
"type" : "string"
},
"url" : {
"type" : "string"
}
}
},
"EnvironmentSpec" : {
"type" : "object",
"properties" : {
"name" : {
"type" : "string"
},
"dockerImage" : {
"type" : "string"
},
"kernelSpec" : {
"$ref" : "#/components/schemas/KernelSpec"
},
"description" : {
"type" : "string"
},
"image" : {
"type" : "string"
}
Expand Down Expand Up @@ -312,13 +335,16 @@
"$ref" : "#/components/schemas/ExperimentMeta"
},
"environment" : {
"$ref" : "#/components/schemas/Environment"
"$ref" : "#/components/schemas/EnvironmentSpec"
},
"spec" : {
"type" : "object",
"additionalProperties" : {
"$ref" : "#/components/schemas/ExperimentTaskSpec"
}
},
"code" : {
"$ref" : "#/components/schemas/CodeSpec"
}
}
},
Expand Down Expand Up @@ -357,7 +383,27 @@
"type" : "string"
}
}
},
"KernelSpec" : {
"type" : "object",
"properties" : {
"name" : {
"type" : "string"
},
"channels" : {
"type" : "array",
"items" : {
"type" : "string"
}
},
"dependencies" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
}
}
}
}
}
}
419 changes: 144 additions & 275 deletions submarine-sdk/pysubmarine/example/submarine_experiment_sdk.ipynb

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion submarine-sdk/pysubmarine/submarine/experiment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
ApiTypeError, ApiValueError,
OpenApiException)
# import models into sdk package
from submarine.experiment.models.environment import Environment
from submarine.experiment.models.code_spec import CodeSpec
from submarine.experiment.models.environment_spec import EnvironmentSpec
from submarine.experiment.models.experiment_meta import ExperimentMeta
from submarine.experiment.models.experiment_spec import ExperimentSpec
from submarine.experiment.models.experiment_task_spec import ExperimentTaskSpec
from submarine.experiment.models.json_response import JsonResponse
from submarine.experiment.models.kernel_spec import KernelSpec

__version__ = "0.5.0-SNAPSHOT"
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
from __future__ import absolute_import

# import models into model package
from submarine.experiment.models.environment import Environment
from submarine.experiment.models.code_spec import CodeSpec
from submarine.experiment.models.environment_spec import EnvironmentSpec
from submarine.experiment.models.experiment_meta import ExperimentMeta
from submarine.experiment.models.experiment_spec import ExperimentSpec
from submarine.experiment.models.experiment_task_spec import ExperimentTaskSpec
from submarine.experiment.models.json_response import JsonResponse
from submarine.experiment.models.kernel_spec import KernelSpec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from submarine.experiment.configuration import Configuration


class Environment(object):
class CodeSpec(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Expand All @@ -49,45 +49,71 @@ class Environment(object):
and the value is json key in definition.
"""
openapi_types = {
'image': 'str'
'sync_mode': 'str',
'url': 'str'
}

attribute_map = {
'image': 'image'
'sync_mode': 'syncMode',
'url': 'url'
}

def __init__(self, image=None, local_vars_configuration=None): # noqa: E501
"""Environment - a model defined in OpenAPI""" # noqa: E501
def __init__(self, sync_mode=None, url=None, local_vars_configuration=None): # noqa: E501
"""CodeSpec - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration

self._image = None
self._sync_mode = None
self._url = None
self.discriminator = None

if image is not None:
self.image = image
if sync_mode is not None:
self.sync_mode = sync_mode
if url is not None:
self.url = url

@property
def image(self):
"""Gets the image of this Environment. # noqa: E501
def sync_mode(self):
"""Gets the sync_mode of this CodeSpec. # noqa: E501
:return: The image of this Environment. # noqa: E501
:return: The sync_mode of this CodeSpec. # noqa: E501
:rtype: str
"""
return self._image
return self._sync_mode

@image.setter
def image(self, image):
"""Sets the image of this Environment.
@sync_mode.setter
def sync_mode(self, sync_mode):
"""Sets the sync_mode of this CodeSpec.
:param image: The image of this Environment. # noqa: E501
:param sync_mode: The sync_mode of this CodeSpec. # noqa: E501
:type: str
"""

self._image = image
self._sync_mode = sync_mode

@property
def url(self):
"""Gets the url of this CodeSpec. # noqa: E501
:return: The url of this CodeSpec. # noqa: E501
:rtype: str
"""
return self._url

@url.setter
def url(self, url):
"""Sets the url of this CodeSpec.
:param url: The url of this CodeSpec. # noqa: E501
:type: str
"""

self._url = url

def to_dict(self):
"""Returns the model properties as a dict"""
Expand Down Expand Up @@ -123,14 +149,14 @@ def __repr__(self):

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, Environment):
if not isinstance(other, CodeSpec):
return False

return self.to_dict() == other.to_dict()

def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, Environment):
if not isinstance(other, CodeSpec):
return True

return self.to_dict() != other.to_dict()
Loading

0 comments on commit b2d3eed

Please sign in to comment.