Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
12cda74
[LIB-837][WIP] working on custom sockets in LIB
opalczynski Aug 10, 2016
460006f
[LIB-837] Add missing docs about custom_sockets; move utils to anothe…
opalczynski Aug 11, 2016
5eca906
[LIB-837] add missing fields in doc string;
opalczynski Aug 11, 2016
c0f75cb
[LIB-837] correct documentation; add possibility to read all endpoint…
opalczynski Aug 12, 2016
e108b5a
[LIB-837] Correct after tests;
opalczynski Aug 12, 2016
5eab464
[LIB-837] another portion of corrects;
opalczynski Aug 12, 2016
1afcd9f
[LIB-837] correct tests again;
opalczynski Aug 12, 2016
48eb08e
[LIB-837] change tests instead of doing a magic in ModelField;
opalczynski Aug 12, 2016
4e2ee33
Language updates
MariuszWisniewski Aug 12, 2016
fe52e7a
[ci skip] readme
MariuszWisniewski Aug 12, 2016
7bc974a
[ci skip] Endpoints readme update
MariuszWisniewski Aug 15, 2016
bc71ad1
[LIB-837] revert ModelField on script in script endpoint model;
opalczynski Aug 16, 2016
327a3fc
[LIB-837] correct data passing on run methods;
opalczynski Aug 16, 2016
d50344b
[LIB-837] correct custom socket behaviour;
opalczynski Aug 16, 2016
c2ffd3a
Merge branch 'LIB-837' of github.com:Syncano/syncano-python into LIB-837
opalczynski Aug 16, 2016
42e4373
[LIB-837] corrects after qa;
opalczynski Aug 16, 2016
04c5ef6
[LIB-837] corrects after qa;
opalczynski Aug 16, 2016
9f5adba
[LIB-837] correct docs examples, polish the tests;
opalczynski Aug 16, 2016
69f3a11
[LIB-837] remove default custom socket in setupclass;
opalczynski Aug 16, 2016
3d1f4dd
[LIB-837] remove default custom socket in setupclass;
opalczynski Aug 16, 2016
d982fd0
[LIB-837] final test correction;
opalczynski Aug 16, 2016
8662e42
Update language
devintyler Aug 16, 2016
0864163
[LIB-837] add possibility to directly point instance name when gettin…
opalczynski Aug 18, 2016
9246b98
[LIB-837] change interface: publish to install in custom socket context;
opalczynski Aug 19, 2016
31c51b9
Merge branch 'LIB-837' of github.com:Syncano/syncano-python into LIB-837
opalczynski Aug 19, 2016
14f6ff7
[LIB-837] add status badges to README
opalczynski Aug 19, 2016
2372986
[LIB-837] small changes after CORE change;
opalczynski Aug 22, 2016
515e50b
[LIB-837] correct SocketEndpoint behaviour (run mainly);
opalczynski Aug 22, 2016
16795dd
[LIB-837] correct run in CustomSocket;
opalczynski Aug 22, 2016
b8c252f
[LIB-837] add possiblity to install from url;
opalczynski Aug 23, 2016
3cf2465
[LIB-837] update documentation for installing socket from url;
opalczynski Aug 23, 2016
ef39be6
[LIB-837] fixes after qa;
opalczynski Aug 24, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[LIB-837] correct docs examples, polish the tests;
  • Loading branch information
opalczynski committed Aug 16, 2016
commit 9f5adba3afaa90a3eae2e0e9a038098a8fe48530
30 changes: 19 additions & 11 deletions docs/source/custom_sockets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@ To create a custom socket follow these steps::
# 4.1 Using a new script - define a new source code.
custom_socket.add_dependency(
ScriptDependency(
name='custom_script'
script=Script(
Script(
runtime_name=RuntimeChoices.PYTHON_V5_0,
source='print("custom_script")'
)
),
name='custom_script'
)
)
# 4.2 Using an existing script.
another_custom_script = Script.please.get(id=2)
custom_socket.add_dependency(
ScriptDependency(
another_custom_script,
name='another_custom_script',
script=another_custom_script
)
)

# 4.3 Using an existing ScriptEndpoint.
script_endpoint = ScriptEndpoint.please.get(name='script_endpoint_name')
custom_socket.add_dependency(
script_endpoint=script_endpoint
script_endpoint
)

# 5. Publish custom_socket.
Expand Down Expand Up @@ -186,11 +186,11 @@ Currently the only supported dependency is a Script.

custom_socket.add_dependency(
ScriptDependency(
name='custom_script'
script=Script(
Script(
runtime_name=RuntimeChoices.PYTHON_V5_0,
source='print("custom_script")'
)
),
name='custom_script'
)
)

Expand All @@ -202,8 +202,8 @@ Currently the only supported dependency is a Script.
another_custom_script = Script.please.get(id=2)
custom_socket.add_dependency(
ScriptDependency(
name='another_custom_script',
script=another_custom_script
another_custom_script,
name='another_custom_script'
)
)

Expand All @@ -213,7 +213,15 @@ Currently the only supported dependency is a Script.

script_endpoint = ScriptEndpoint.please.get(name='script_endpoint_name')
custom_socket.add_dependency(
script_endpoint=script_endpoint
script_endpoint
)

You can overwrite the name in the following way::

script_endpoint = ScriptEndpoint.please.get(name='script_endpoint_name')
custom_socket.add_dependency(
script_endpoint,
name='custom_name'
)

Custom socket recheck
Expand Down
4 changes: 3 additions & 1 deletion syncano/models/custom_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class CustomSocket(EndpointMetadataMixin, DependencyMetadataMixin, Model):
metadata = fields.JSONField(read_only=True, required=False)
status = fields.StringField(read_only=True, required=False)
status_info = fields.StringField(read_only=True, required=False)
created_at = fields.DateTimeField(read_only=True, required=False)
updated_at = fields.DateTimeField(read_only=True, required=False)
links = fields.LinksField()

class Meta:
Expand All @@ -52,7 +54,7 @@ def get_endpoints(self):

def run(self, endpoint_name, method='GET', data=None):
endpoint = self._find_endpoint(endpoint_name)
return endpoint.run(method, data=data or {})
return endpoint.run(method=method, data=data or {})

def _find_endpoint(self, endpoint_name):
endpoints = self.get_endpoints()
Expand Down
11 changes: 9 additions & 2 deletions tests/integration_test_custom_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CustomSocketTest(InstanceMixin, IntegrationTest):
def setUpClass(cls):
super(CustomSocketTest, cls).setUpClass()
cls.custom_socket = cls._create_custom_socket('default', cls._define_dependencies_new_script_endpoint)
cls._assert_custom_socket(cls.custom_socket)

def test_publish_custom_socket(self):
# this test new ScriptEndpoint dependency create;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests

Expand Down Expand Up @@ -70,7 +71,7 @@ def test_fetching_all_endpoints(self):
self.assertTrue(all_endpoints[0].name)

def test_endpoint_run(self):
script_endpoint = SocketEndpoint.please.first()
script_endpoint = SocketEndpoint.get_all_endpoints()[0]
result = script_endpoint.run()
suffix = script_endpoint.name.split('_')[-1]
self.assertTrue(result.result['stdout'].endswith(suffix))
Expand All @@ -92,7 +93,13 @@ def test_custom_socket_update(self):

def assert_custom_socket(self, suffix, dependency_method):
custom_socket = self._create_custom_socket(suffix, dependency_method=dependency_method)
self.assertTrue(custom_socket.name)
self._assert_custom_socket(custom_socket)

@classmethod
def _assert_custom_socket(cls, custom_socket):
cls.assertTrue(custom_socket.name)
cls.assertTrue(custom_socket.created_at)
cls.assertTrue(custom_socket.updated_at)

@classmethod
def _create_custom_socket(cls, suffix, dependency_method):
Expand Down