[GitHub] incubator-ariatosca pull request #132: ARIA-171 service_template.services ty...

2017-05-15 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/132

ARIA-171 service_template.services type inconsistency

As opposed to service_template.node_templates and service.nodes
which have a dict interface, service_template.services
had a list interface. That seemed as inconsistent, so the former
interface was changed to a dict interface as well.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-171-service-template-services-type-inconsistency

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/132.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #132


commit 4425c10306517cffce930b3f81623f350a116fae
Author: Avia Efrat <a...@gigaspaces.com>
Date:   2017-05-15T11:26:34Z

ARIA-171 service_template.services type inconsistency

As opposed to service_template.node_templates and service.nodes
which have a dict interface, service_template.services
had a list interface. That seemed as inconsistent, so the former
interface was changed to a dict interface as well.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #131: ARIA-157 Failing CLI service-template...

2017-05-10 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/131

ARIA-157 Failing CLI service-templates store tests on Windows

Three tests from `aria service-templates store` failed on Windows, but
not on Linux.

The reason for this failures was differing implementation of
os.path.dirname across the platforms.

Python implements os.path.dirname in the ntpath module. There, somewhere
down the line of calls, (a part of) the argument of dirname is tested
for membership in a string (using `in`). In these three tests, the
argument of dirname is of type MagicMock, and an error is raised since
only a string can be tested for membership in a string.

The solution was to mock the dirname calls.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-157-cli-service-template-store-tests-fail-in-windows

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/131.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #131


commit 6864d42e1748b5cd8ecc596fc1b4adc04b0cc9ba
Author: Avia Efrat <a...@gigaspaces.com>
Date:   2017-05-10T14:39:49Z

ARIA-157 Failing CLI service-templates store tests on Windows

Three tests from `aria service-templates store` failed on Windows, but
not on Linux.

The reason for this failures was differing implementation of
os.path.dirname across the platforms.

Python implements os.path.dirname in the ntpath module. There, somewhere
down the line of calls, (a part of) the argument of dirname is tested
for membership in a string (using `in`). In these three tests, the
argument of dirname is of type MagicMock, and an error is raised since
only a string can be tested for membership in a string.

The solution was to mock the dirname calls.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca issue #100: ARIA-140 Version utils

2017-05-09 Thread AviaE
Github user AviaE commented on the issue:

https://github.com/apache/incubator-ariatosca/pull/100
  
@tliron and I discussed his replies via zoom, and this pull request is free 
to merge (with minor changes).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #128: ARIA-210 Handle relative paths in CLI...

2017-05-09 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/128#discussion_r115502906
  
--- Diff: tests/cli/test_service_templates.py ---
@@ -244,3 +258,13 @@ def test_create_archive_successful(self, monkeypatch, 
mock_object):
 monkeypatch.setattr(csar, 'write', mock_object)
 self.invoke('service_templates create_archive stubpath stubdest')
 assert 'CSAR archive created at stubdest' in 
self.logger_output_string
+
+def test_create_archive_from_relative_path(self, monkeypatch, 
mock_object):
+
+monkeypatch.setattr(os.path, 'isfile', lambda x: True)
+monkeypatch.setattr(os.path, 'isfile', mock_object)
--- End diff --

Indeed. So I removed that line.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #128: ARIA-210 Handle relative paths in CLI...

2017-05-09 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/128#discussion_r115501254
  
--- Diff: aria/cli/service_template_utils.py ---
@@ -53,7 +53,7 @@ def get(source, service_template_filename):
 return _get_service_template_file_from_archive(source, 
service_template_filename)
--- End diff --

Added tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #128: ARIA-210 Handle relative paths in CLI...

2017-05-08 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/128

ARIA-210 Handle relative paths in CLI service-templates

This was a rather simple change, mainly involving adding absolute path
references.

The problems were only in `service-templates store` and in
`service-templates create-archive`.
`service-templates validate` was not affected.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-210-handle-relative-paths-in-cli-service-templates

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/128.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #128


commit 0a3ea7991d6218438318d93232f82e7d7d42d4ae
Author: Avia Efrat <a...@gigaspaces.com>
Date:   2017-05-08T14:45:23Z

ARIA-210 Handle relative paths in CLI service-templates

This was a rather simple change, mainly involving adding absolute path
references.

The problems were only in `service-templates store` and in
`service-templates create-archive`.
`service-templates validate` was not affected.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115142886
  
--- Diff: aria/utils/versions.py ---
@@ -0,0 +1,162 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+"""
+General-purpose version string handling
+"""
+
+import re
+
+
+_INF = float('inf')
+
+_NULL = (), _INF
+
+_DIGITS_RE = re.compile(r'^\d+$')
+
+_PREFIXES = {
+'dev':   0.0001,
+'alpha': 0.001,
+'beta':  0.01,
+'rc':0.1
+}
+
+
+class VersionString(unicode):
+"""
+Version string that can be compared, sorted, made unique in a set, and 
used as a unique dict
+key.
+
+The primary part of the string is one or more dot-separated natural 
numbers. Trailing zeroes
+are treated as redundant, e.g. "1.0.0" == "1.0" == "1".
+
+An optional qualifier can be added after a "-". The qualifier can be a 
natural number or a
+specially treated prefixed natural number, e.g. "1.1-beta1" > 
"1.1-alpha2". The case of the
+prefix is ignored.
+
+Numeric qualifiers will always be greater than prefixed integer 
qualifiers, e.g. "1.1-1" >
+"1.1-beta1".
+
+Versions without a qualifier will always be greater than their 
equivalents with a qualifier,
+e.g. e.g. "1.1" > "1.1-1".
+
+Any value that does not conform to this format will be treated as a 
zero version, which would
+be lesser than any non-zero version.
+
+For efficient list sorts use the ``key`` property, e.g.:
+``sorted(versions, key=lambda x: x.key)``
+"""
+
+NULL = None # initialized below
+
+def __init__(self, value=None):
+if value is not None:
+super(VersionString, self).__init__(value)
+self.key = parse_version_string(self)
+
+def __eq__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key == version.key
+
+def __lt__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key < version.key
+
+def __hash__(self):
+return self.key.__hash__()
+
+
+def parse_version_string(version): # pylint: disable=too-many-branches
+"""
+Parses a version string.
+
+:param version: The version string
+:returns: The primary tuple and qualifier float
+:rtype: ((int), float)
+"""
+
+if version is None:
+return _NULL
+version = unicode(version)
+
+# Split to primary and qualifier on '-'
+split = version.split('-', 2)
+if len(split) == 2:
+primary, qualifier = split
+else:
--- End diff --

The `2` in `split` means you include the part to the right of the second 
separator as the third element in the result.
Which means that if you get passed `1.2-3-beta4`, you will treat it as a 
valid version string with the value `1.2`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115141677
  
--- Diff: aria/modeling/service_template.py ---
@@ -33,7 +33,8 @@
 from ..parser import validation
 from ..parser.consumption import ConsumptionContext
 from ..parser.reading import deepcopy_with_locators
-from ..utils import collections, formatting, console
+from ..utils import (collections, formatting, console)
--- End diff --

According to 
https://cwiki.apache.org/confluence/display/ARIATOSCA/Code+Style+Guidelines, 
section 5c, these should be separated into multiple lines.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115145936
  
--- Diff: aria/modeling/service_template.py ---
@@ -33,7 +33,8 @@
 from ..parser import validation
--- End diff --

Please expand the commit message by adding information on the purpose of 
your change/addition.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115142636
  
--- Diff: aria/utils/versions.py ---
@@ -0,0 +1,162 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+"""
+General-purpose version string handling
+"""
+
+import re
+
+
+_INF = float('inf')
+
+_NULL = (), _INF
+
+_DIGITS_RE = re.compile(r'^\d+$')
+
+_PREFIXES = {
+'dev':   0.0001,
+'alpha': 0.001,
+'beta':  0.01,
+'rc':0.1
+}
+
+
+class VersionString(unicode):
+"""
+Version string that can be compared, sorted, made unique in a set, and 
used as a unique dict
+key.
+
+The primary part of the string is one or more dot-separated natural 
numbers. Trailing zeroes
+are treated as redundant, e.g. "1.0.0" == "1.0" == "1".
+
+An optional qualifier can be added after a "-". The qualifier can be a 
natural number or a
+specially treated prefixed natural number, e.g. "1.1-beta1" > 
"1.1-alpha2". The case of the
+prefix is ignored.
+
+Numeric qualifiers will always be greater than prefixed integer 
qualifiers, e.g. "1.1-1" >
+"1.1-beta1".
+
+Versions without a qualifier will always be greater than their 
equivalents with a qualifier,
+e.g. e.g. "1.1" > "1.1-1".
+
+Any value that does not conform to this format will be treated as a 
zero version, which would
+be lesser than any non-zero version.
+
+For efficient list sorts use the ``key`` property, e.g.:
+``sorted(versions, key=lambda x: x.key)``
+"""
+
+NULL = None # initialized below
+
+def __init__(self, value=None):
+if value is not None:
+super(VersionString, self).__init__(value)
+self.key = parse_version_string(self)
+
+def __eq__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key == version.key
+
+def __lt__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key < version.key
+
+def __hash__(self):
+return self.key.__hash__()
+
+
+def parse_version_string(version): # pylint: disable=too-many-branches
+"""
+Parses a version string.
+
+:param version: The version string
+:returns: The primary tuple and qualifier float
+:rtype: ((int), float)
+"""
+
+if version is None:
+return _NULL
+version = unicode(version)
+
+# Split to primary and qualifier on '-'
+split = version.split('-', 2)
+if len(split) == 2:
+primary, qualifier = split
+else:
+primary = split[0]
+qualifier = None
+
+# Parse primary
+split = primary.split('.')
+primary = []
+for element in split:
+if _DIGITS_RE.match(element) is None:
+# Invalid version string
+return _NULL
+try:
+element = int(element)
+except ValueError:
+# Invalid version string
+return _NULL
+primary.append(element)
+
+# Remove redundant zeros
+for element in reversed(primary):
+if element == 0:
+primary.pop()
+else:
+break
+primary = tuple(primary)
+
+# Parse qualifier
+if qualifier is not None:
+if _DIGITS_RE.match(qualifier) is not None:
+# Integer qualifer
+try:
+qualifier = float(int(

[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115141706
  
--- Diff: aria/modeling/service_template.py ---
@@ -2131,13 +2132,15 @@ def resolve(self, model_storage):
 # moved to.
 plugins = model_storage.plugin.list()
 matching_plugins = []
-for plugin in plugins:
-# TODO: we need to use a version comparator
-if (plugin.name == self.name) and \
-((self.version is None) or (plugin.package_version >= 
self.version)):
-matching_plugins.append(plugin)
+if plugins:
+for plugin in plugins:
+if (plugin.name == self.name) and \
--- End diff --

I know that wrapping `if` conditions with parenthesis is your thing, but in 
this case it seems to cause some clutter...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115142635
  
--- Diff: aria/utils/versions.py ---
@@ -0,0 +1,162 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+"""
+General-purpose version string handling
+"""
+
+import re
+
+
+_INF = float('inf')
+
+_NULL = (), _INF
+
+_DIGITS_RE = re.compile(r'^\d+$')
+
+_PREFIXES = {
+'dev':   0.0001,
+'alpha': 0.001,
+'beta':  0.01,
+'rc':0.1
+}
+
+
+class VersionString(unicode):
+"""
+Version string that can be compared, sorted, made unique in a set, and 
used as a unique dict
+key.
+
+The primary part of the string is one or more dot-separated natural 
numbers. Trailing zeroes
+are treated as redundant, e.g. "1.0.0" == "1.0" == "1".
+
+An optional qualifier can be added after a "-". The qualifier can be a 
natural number or a
+specially treated prefixed natural number, e.g. "1.1-beta1" > 
"1.1-alpha2". The case of the
+prefix is ignored.
+
+Numeric qualifiers will always be greater than prefixed integer 
qualifiers, e.g. "1.1-1" >
+"1.1-beta1".
+
+Versions without a qualifier will always be greater than their 
equivalents with a qualifier,
+e.g. e.g. "1.1" > "1.1-1".
+
+Any value that does not conform to this format will be treated as a 
zero version, which would
+be lesser than any non-zero version.
+
+For efficient list sorts use the ``key`` property, e.g.:
+``sorted(versions, key=lambda x: x.key)``
+"""
+
+NULL = None # initialized below
+
+def __init__(self, value=None):
+if value is not None:
+super(VersionString, self).__init__(value)
+self.key = parse_version_string(self)
+
+def __eq__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key == version.key
+
+def __lt__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key < version.key
+
+def __hash__(self):
+return self.key.__hash__()
+
+
+def parse_version_string(version): # pylint: disable=too-many-branches
+"""
+Parses a version string.
+
+:param version: The version string
+:returns: The primary tuple and qualifier float
+:rtype: ((int), float)
+"""
+
+if version is None:
+return _NULL
+version = unicode(version)
+
+# Split to primary and qualifier on '-'
+split = version.split('-', 2)
+if len(split) == 2:
+primary, qualifier = split
+else:
+primary = split[0]
+qualifier = None
+
+# Parse primary
+split = primary.split('.')
+primary = []
+for element in split:
+if _DIGITS_RE.match(element) is None:
+# Invalid version string
+return _NULL
+try:
+element = int(element)
+except ValueError:
+# Invalid version string
+return _NULL
+primary.append(element)
+
+# Remove redundant zeros
+for element in reversed(primary):
+if element == 0:
+primary.pop()
+else:
+break
+primary = tuple(primary)
+
+# Parse qualifier
+if qualifier is not None:
+if _DIGITS_RE.match(qualifier) is not None:
+# Integer qualifer
+try:
--- End diff --

Same as before, what can be a 

[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115141664
  
--- Diff: aria/utils/versions.py ---
@@ -0,0 +1,162 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+"""
+General-purpose version string handling
+"""
+
+import re
+
+
+_INF = float('inf')
+
+_NULL = (), _INF
+
+_DIGITS_RE = re.compile(r'^\d+$')
+
+_PREFIXES = {
+'dev':   0.0001,
+'alpha': 0.001,
+'beta':  0.01,
+'rc':0.1
+}
+
+
+class VersionString(unicode):
+"""
+Version string that can be compared, sorted, made unique in a set, and 
used as a unique dict
+key.
+
+The primary part of the string is one or more dot-separated natural 
numbers. Trailing zeroes
+are treated as redundant, e.g. "1.0.0" == "1.0" == "1".
+
+An optional qualifier can be added after a "-". The qualifier can be a 
natural number or a
+specially treated prefixed natural number, e.g. "1.1-beta1" > 
"1.1-alpha2". The case of the
+prefix is ignored.
+
+Numeric qualifiers will always be greater than prefixed integer 
qualifiers, e.g. "1.1-1" >
+"1.1-beta1".
+
+Versions without a qualifier will always be greater than their 
equivalents with a qualifier,
+e.g. e.g. "1.1" > "1.1-1".
+
+Any value that does not conform to this format will be treated as a 
zero version, which would
+be lesser than any non-zero version.
+
+For efficient list sorts use the ``key`` property, e.g.:
+``sorted(versions, key=lambda x: x.key)``
+"""
+
+NULL = None # initialized below
+
+def __init__(self, value=None):
+if value is not None:
+super(VersionString, self).__init__(value)
+self.key = parse_version_string(self)
+
+def __eq__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key == version.key
+
+def __lt__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key < version.key
+
+def __hash__(self):
+return self.key.__hash__()
+
+
+def parse_version_string(version): # pylint: disable=too-many-branches
+"""
+Parses a version string.
+
+:param version: The version string
+:returns: The primary tuple and qualifier float
+:rtype: ((int), float)
+"""
+
+if version is None:
+return _NULL
+version = unicode(version)
--- End diff --

This line will always be called, since `version` cannot be `None`.
And except the case when `VersionString` is called with no arguments, this 
line was already called in `__init__`.
In addition, in all of your tests, you never pass through line 93.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115142924
  
--- Diff: aria/utils/versions.py ---
@@ -0,0 +1,162 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+"""
+General-purpose version string handling
+"""
+
+import re
+
+
+_INF = float('inf')
+
+_NULL = (), _INF
--- End diff --

Why is `_NULL` not `(), 0`? Seems more natural, as it represents an invalid 
version string.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115145852
  
--- Diff: aria/utils/versions.py ---
@@ -0,0 +1,162 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+"""
+General-purpose version string handling
+"""
+
+import re
+
+
+_INF = float('inf')
+
+_NULL = (), _INF
+
+_DIGITS_RE = re.compile(r'^\d+$')
+
+_PREFIXES = {
+'dev':   0.0001,
+'alpha': 0.001,
+'beta':  0.01,
+'rc':0.1
+}
+
+
+class VersionString(unicode):
+"""
+Version string that can be compared, sorted, made unique in a set, and 
used as a unique dict
+key.
+
+The primary part of the string is one or more dot-separated natural 
numbers. Trailing zeroes
+are treated as redundant, e.g. "1.0.0" == "1.0" == "1".
+
+An optional qualifier can be added after a "-". The qualifier can be a 
natural number or a
+specially treated prefixed natural number, e.g. "1.1-beta1" > 
"1.1-alpha2". The case of the
+prefix is ignored.
+
+Numeric qualifiers will always be greater than prefixed integer 
qualifiers, e.g. "1.1-1" >
+"1.1-beta1".
+
+Versions without a qualifier will always be greater than their 
equivalents with a qualifier,
+e.g. e.g. "1.1" > "1.1-1".
+
+Any value that does not conform to this format will be treated as a 
zero version, which would
+be lesser than any non-zero version.
+
+For efficient list sorts use the ``key`` property, e.g.:
+``sorted(versions, key=lambda x: x.key)``
+"""
+
+NULL = None # initialized below
+
+def __init__(self, value=None):
+if value is not None:
+super(VersionString, self).__init__(value)
+self.key = parse_version_string(self)
+
+def __eq__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key == version.key
+
+def __lt__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key < version.key
+
+def __hash__(self):
+return self.key.__hash__()
+
+
+def parse_version_string(version): # pylint: disable=too-many-branches
+"""
+Parses a version string.
+
+:param version: The version string
+:returns: The primary tuple and qualifier float
+:rtype: ((int), float)
+"""
+
+if version is None:
+return _NULL
+version = unicode(version)
+
+# Split to primary and qualifier on '-'
+split = version.split('-', 2)
+if len(split) == 2:
+primary, qualifier = split
+else:
+primary = split[0]
+qualifier = None
+
+# Parse primary
+split = primary.split('.')
+primary = []
+for element in split:
+if _DIGITS_RE.match(element) is None:
+# Invalid version string
+return _NULL
+try:
+element = int(element)
+except ValueError:
+# Invalid version string
+return _NULL
+primary.append(element)
+
+# Remove redundant zeros
+for element in reversed(primary):
+if element == 0:
+primary.pop()
+else:
+break
+primary = tuple(primary)
+
+# Parse qualifier
+if qualifier is not None:
+if _DIGITS_RE.match(qualifier) is not None:
+# Integer qualifer
+try:
+qualifier = float(int(

[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115142082
  
--- Diff: aria/utils/versions.py ---
@@ -0,0 +1,162 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+"""
+General-purpose version string handling
+"""
+
+import re
+
+
+_INF = float('inf')
+
+_NULL = (), _INF
+
+_DIGITS_RE = re.compile(r'^\d+$')
+
+_PREFIXES = {
+'dev':   0.0001,
+'alpha': 0.001,
+'beta':  0.01,
+'rc':0.1
+}
+
+
+class VersionString(unicode):
+"""
+Version string that can be compared, sorted, made unique in a set, and 
used as a unique dict
+key.
+
+The primary part of the string is one or more dot-separated natural 
numbers. Trailing zeroes
+are treated as redundant, e.g. "1.0.0" == "1.0" == "1".
+
+An optional qualifier can be added after a "-". The qualifier can be a 
natural number or a
+specially treated prefixed natural number, e.g. "1.1-beta1" > 
"1.1-alpha2". The case of the
+prefix is ignored.
+
+Numeric qualifiers will always be greater than prefixed integer 
qualifiers, e.g. "1.1-1" >
+"1.1-beta1".
+
+Versions without a qualifier will always be greater than their 
equivalents with a qualifier,
+e.g. e.g. "1.1" > "1.1-1".
+
+Any value that does not conform to this format will be treated as a 
zero version, which would
+be lesser than any non-zero version.
+
+For efficient list sorts use the ``key`` property, e.g.:
+``sorted(versions, key=lambda x: x.key)``
+"""
+
+NULL = None # initialized below
+
+def __init__(self, value=None):
+if value is not None:
+super(VersionString, self).__init__(value)
+self.key = parse_version_string(self)
+
+def __eq__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key == version.key
+
+def __lt__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key < version.key
+
+def __hash__(self):
+return self.key.__hash__()
+
+
+def parse_version_string(version): # pylint: disable=too-many-branches
+"""
+Parses a version string.
+
+:param version: The version string
+:returns: The primary tuple and qualifier float
+:rtype: ((int), float)
+"""
+
+if version is None:
+return _NULL
+version = unicode(version)
+
+# Split to primary and qualifier on '-'
+split = version.split('-', 2)
+if len(split) == 2:
+primary, qualifier = split
+else:
+primary = split[0]
+qualifier = None
+
+# Parse primary
+split = primary.split('.')
+primary = []
+for element in split:
+if _DIGITS_RE.match(element) is None:
+# Invalid version string
+return _NULL
+try:
--- End diff --

If, on the previous `if`, we ensured that the element is a sequence of 
numbers, what bad things can happen when trying to convert it into an `int`?
i.e, why is this stage necessary?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #100: ARIA-140 Version utils

2017-05-07 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/100#discussion_r115144550
  
--- Diff: aria/utils/versions.py ---
@@ -0,0 +1,162 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+"""
+General-purpose version string handling
+"""
+
+import re
+
+
+_INF = float('inf')
+
+_NULL = (), _INF
+
+_DIGITS_RE = re.compile(r'^\d+$')
+
+_PREFIXES = {
+'dev':   0.0001,
+'alpha': 0.001,
+'beta':  0.01,
+'rc':0.1
+}
+
+
+class VersionString(unicode):
+"""
+Version string that can be compared, sorted, made unique in a set, and 
used as a unique dict
+key.
+
+The primary part of the string is one or more dot-separated natural 
numbers. Trailing zeroes
+are treated as redundant, e.g. "1.0.0" == "1.0" == "1".
+
+An optional qualifier can be added after a "-". The qualifier can be a 
natural number or a
+specially treated prefixed natural number, e.g. "1.1-beta1" > 
"1.1-alpha2". The case of the
+prefix is ignored.
+
+Numeric qualifiers will always be greater than prefixed integer 
qualifiers, e.g. "1.1-1" >
+"1.1-beta1".
+
+Versions without a qualifier will always be greater than their 
equivalents with a qualifier,
+e.g. e.g. "1.1" > "1.1-1".
+
+Any value that does not conform to this format will be treated as a 
zero version, which would
+be lesser than any non-zero version.
+
+For efficient list sorts use the ``key`` property, e.g.:
+``sorted(versions, key=lambda x: x.key)``
+"""
+
+NULL = None # initialized below
+
+def __init__(self, value=None):
+if value is not None:
+super(VersionString, self).__init__(value)
+self.key = parse_version_string(self)
+
+def __eq__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key == version.key
+
+def __lt__(self, version):
+if not isinstance(version, VersionString):
+version = VersionString(version)
+return self.key < version.key
+
+def __hash__(self):
+return self.key.__hash__()
+
+
+def parse_version_string(version): # pylint: disable=too-many-branches
+"""
+Parses a version string.
+
+:param version: The version string
+:returns: The primary tuple and qualifier float
+:rtype: ((int), float)
+"""
+
+if version is None:
--- End diff --

How can version be `None` here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #121: ARIA-143 Better handle exceptions in ...

2017-05-07 Thread AviaE
Github user AviaE closed the pull request at:

https://github.com/apache/incubator-ariatosca/pull/121


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #121: ARIA-143 Better handle exceptions in ...

2017-05-07 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/121

ARIA-143 Better handle exceptions in the process executor

Previously, if an exception was raised during the starting of a task,
the task's process was permenantly blocked on receiving a message.

The reason was that the execption caused the 'listener thread' to
not send a response the to the task's process, as the exception was not 
handled inside the 'with' block of the listener thread.

The first change I introduced was to wrap the yielding of the message and
the response inside a try-except-finally block, so the exception will be
handled within the 'with' scope, and to ensure a response is sent to the
task's process.

The second change is to move the sending of the 'task started' message in
the task's process to a place where encountering an exception will be
handled via sending a 'task failed' message back to the listener thread.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-143-better-handle-exceptions-in-the-process-executor

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/121.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #121


commit e5c6522cfefffe699ab742c790d102ebce227090
Author: Avia Efrat <a...@gigaspaces.com>
Date:   2017-05-07T08:42:58Z

ARIA-143 Better handle exceptions in the process executor

Previously, if an exception was raised during the starting of a task,
the task's process was permenantly blocked on receiving a message.

The reason was that the execption caused the 'listener thread' to
not send a response the to the task's process, as the exception was not 
handled inside the 'with' block of the listener thread.

The first change I introduced was to wrap the yielding of the message and
the response inside a try-except-finally block, so the exception will be
handled within the 'with' scope, and to ensure a response is sent to the
task's process.

The second change is to move the sending of the 'task started' message in
the task's process to a place where encountering an exception will be
handled via sending a 'task failed' message back to the listener thread.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #110: Improve execution cancelling

2017-04-25 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/110

Improve execution cancelling

Unhandled execution status transitions resulting from cancelling an
execution via the CLI, that we indentified and tried to address:

1. TERMINATED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already finished, and therefore, in
SUCCEEDED status.

2. FAILED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already encountered an error, and 
therefore, in
FAILED state.

3. TERMINATED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

4. FAILED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

In all of the above cases (#1-#4), we skip updating the execution status,
and log that the execution already succeeded/failed before we were able
to cancel it.

5. CANCELLING -> STARTED
You cancel the execution while it is still in pending state. Meanwhile,
while the execution status was already set to CANCELLING, we try to set
the execution status

6. CANCELLED -> STARTED
Similar to #5, but after the status is set to CANCELLING, it also gets
set to CANCELLED before attempting to set it to STARTED.

In cases #5-#6, we skip updtating the execution status, and nothing is 
logged.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-143-improve-cancelling-of-workflow-execution

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/110.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #110


commit 4e81d7fff45bae1a2ccb9f0b897179c95076cf3f
Author: Avia Efrat <a...@gigaspaces.com>
Date:   2017-04-20T10:23:32Z

Improve execution cancelling

Unhandled execution status transitions resulting from cancelling an
execution via the CLI, that we indentified and tried to address:

1. TERMINATED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already finished, and therefore, in
SUCCEEDED status.

2. FAILED -> CANCELLING
You cancel the execution, but by the time we try to set the status to
CANCELLING, the execution thread had already encountered an error, and 
therefore, in
FAILED state.

3. TERMINATED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

4. FAILED -> CANCELLED
Similar to #1, but with CANCELLED instead of CANCELLING.

In all of the above cases (#1-#4), we skip updating the execution status,
and log that the execution already succeeded/failed before we were able
to cancel it.

5. CANCELLING -> STARTED
You cancel the execution while it is still in pending state. Meanwhile,
while the execution status was already set to CANCELLING, we try to set
the execution status

6. CANCELLED -> STARTED
Similar to #5, but after the status is set to CANCELLING, it also gets
set to CANCELLED before attempting to set it to STARTED.

In cases #5-#6, we skip updtating the execution status, and nothing is 
logged.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #87: Show tracebacks on console when in deb...

2017-03-29 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/87

Show tracebacks on console when in debug logging mode



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca avia-cli

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/87.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #87


commit f9680e38c01f5f54a99abd7cfe3e7d6cd0e5f746
Author: Avia Efrat <a...@gigaspaces.com>
Date:   2017-03-29T16:57:38Z

Show tracebacks on console when in debug logging mode




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #85: Add is_active and is_ended methods to ...

2017-03-28 Thread AviaE
Github user AviaE closed the pull request at:

https://github.com/apache/incubator-ariatosca/pull/85


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #86: Add status-related methods to the Exec...

2017-03-28 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/86

Add status-related methods to the Execution, Task and Node models

We are adding these methods so it will be easier to filter those models
from storage according to their status, and to not make use of the their
`status` constants outside of the models themselves.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-133-Add-status-related-methods-to-Execution-Task-and-Node-models

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/86.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #86


commit 77e35d02b64eb9483da7150631160ea80385383f
Author: Avia Efrat <a...@gigaspaces.com>
Date:   2017-03-28T09:51:42Z

Add status-related methods to the Execution, Task and Node models

We are adding these methods so it will be easier to filter those models
from storage according to their status, and to not make use of the their
`status` constants outside of the models themselves.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #83: ARIA-126 Add node states

2017-03-27 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/83#discussion_r108059158
  
--- Diff: aria/modeling/service_instance.py ---
@@ -18,7 +18,9 @@
 from sqlalchemy import (
 Column,
 Text,
-Integer
+Integer,
+Enum,
+orm
--- End diff --

Remove


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #83: ARIA-126 Add node states

2017-03-27 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/83#discussion_r108059270
  
--- Diff: aria/modeling/service_instance.py ---
@@ -347,6 +349,46 @@ class NodeBase(InstanceModelMixin): # pylint: 
disable=too-many-public-methods
   'node_template_fk',
   'service_name']
 
+INITIAL = 'initial'
+CREATING = 'creating'
+CREATED = 'created'
+CONFIGURING = 'configuring'
+CONFIGURED = 'configured'
+STARTING = 'starting'
+STARTED = 'started'
+STOPPING = 'stopping'
+DELETING = 'deleting'
+DELETED = 'deleted'
--- End diff --

Write a comment that describes what 'deleted' means to us.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #83: ARIA-126 Add node states

2017-03-27 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/83#discussion_r108060149
  
--- Diff: tests/orchestrator/workflows/core/test_events.py ---
@@ -0,0 +1,130 @@
+import pytest
--- End diff --

license


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #83: ARIA-126 Add node states

2017-03-27 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/83#discussion_r108060157
  
--- Diff: tests/orchestrator/workflows/core/test_events.py ---
@@ -0,0 +1,130 @@
+import pytest
--- End diff --

import style


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #83: ARIA-126 Add node states

2017-03-27 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/83#discussion_r108059849
  
--- Diff: aria/orchestrator/workflows/core/events_handler.py ---
@@ -73,6 +82,10 @@ def _task_succeeded(task, *args, **kwargs):
 task.ended_at = datetime.utcnow()
 task.status = task.SUCCESS
 
+# update node state if necessary
+if type(task) is OperationTask and type(task.context) is 
NodeOperationContext:
--- End diff --

remove the 'ifs'. call the function `update node state of necessary.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #83: ARIA-126 Add node states

2017-03-27 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/83#discussion_r108060063
  
--- Diff: aria/modeling/service_instance.py ---
@@ -347,6 +349,46 @@ class NodeBase(InstanceModelMixin): # pylint: 
disable=too-many-public-methods
   'node_template_fk',
   'service_name']
 
+INITIAL = 'initial'
+CREATING = 'creating'
+CREATED = 'created'
+CONFIGURING = 'configuring'
+CONFIGURED = 'configured'
+STARTING = 'starting'
+STARTED = 'started'
+STOPPING = 'stopping'
+DELETING = 'deleting'
+DELETED = 'deleted'
+# TODO decide what happens to a node's state after its 'deleting' 
state, as
+# this is not defined as part of the tosca spec.
+ERROR = 'error'
+
+STATES = [INITIAL, CREATING, CREATED, CONFIGURING, CONFIGURED, 
STARTING, STARTED, STOPPING,
+  DELETING, DELETED, ERROR]
+
+_op_to_state = {'create': {'transitional': CREATING, 'finished': 
CREATED},
+'configure': {'transitional': CONFIGURING, 'finished': 
CONFIGURED},
+'start': {'transitional': STARTING, 'finished': 
STARTED},
+'stop': {'transitional': STOPPING, 'finished': 
CONFIGURED},
+'delete': {'transitional': DELETING, 'finished': 
DELETED}}
+
+@classmethod
+def determine_state(cls, op_name, transitional):
--- End diff --

is_transitional


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #83: ARIA-126 Add node states

2017-03-27 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/83#discussion_r108059345
  
--- Diff: aria/orchestrator/workflows/core/events_handler.py ---
@@ -20,14 +20,19 @@
 Implementation of storage handlers for workflow and operation events.
 """
 
+import re
 
--- End diff --

write imports according to convention


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #83: ARIA-126 Add node states

2017-03-27 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/83#discussion_r108059379
  
--- Diff: aria/orchestrator/workflows/core/events_handler.py ---
@@ -20,14 +20,19 @@
 Implementation of storage handlers for workflow and operation events.
 """
 
+import re
 
 from datetime import (
 datetime,
 timedelta,
 )
 
+from aria.orchestrator.workflows.core.task import OperationTask
+
 from ... import events
 from ... import exceptions
+from ... context.operation import NodeOperationContext
--- End diff --

Check how to import properly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #83: ARIA-126 Add node states

2017-03-26 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/83

ARIA-126 Add node states

1. The states are described in section 3.3.1 of the TOSCA spec.

2. The state is changed if a standard lifecycle operation runs of the
node, as described in sections 5.7.4.1, 5.7.4.4.1, and 5.7.4.4.2 of the 
TOSCA spec.

3. We did not address the 'error' state yet.
This state is defined as part of the possible node states in the model, but 
currently no execution path leads to setting a node's state to 'error'.

4. No validation of state transiontions.
For example, we do not validate if a node goes from 'created'
to 'started' without going through the 'configured' state in between.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-126-update-node-statuses

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/83.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #83


commit d74baa7895297bdcd190afdf823d3a70d2429e42
Author: Avia Efrat <a...@gigaspaces.com>
Date:   2017-03-22T15:19:58Z

ARIA-126 Add node states

1. The states are described in section 3.3.1 of the TOSCA spec.

2. The state is changed if a standard lifecycle operation runs of the
node, as described in sections 5.7.4.1, 5.7.4.4.1, and 5.7.4.4.2 of the 
TOSCA spec.

3. We did not address the 'error' state yet.
This state is defined as part of the possible node states in the model, but 
currently no execution path leads to setting a node's state to 'error'.

4. No validation of state transiontions.
For example, we do not validate if a node goes from 'created'
to 'started' without going through the 'configured' state in between.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #79: Improve our requirements handling

2017-03-20 Thread AviaE
Github user AviaE commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/79#discussion_r106884338
  
--- Diff: setup.py ---
@@ -44,16 +44,17 @@
 # We need to parse the requirements for the conditional dependencies to 
work for wheels and
 # standard installation
 try:
-with open(os.path.join(root_dir, 'requirements.txt')) as requirements:
+with open(os.path.join(root_dir, 'requirements.in')) as requirements:
 for requirement in requirements.readlines():
-if not requirement.strip().startswith('#'):
-if ';' in requirement:
-package, condition = requirement.split(';')
-cond_name = ':{0}'.format(condition.strip())
-extras_require.setdefault(cond_name, [])
-extras_require[cond_name].append(package.strip())
-else:
-install_requires.append(requirement.strip())
+install_requires.append(requirement.strip())
+# We are using the install_requires mechanism in order to specify
+# conditional dependencies since reading them from a file in their
+# standard ';' from does silently nothing.
--- End diff --

from->form


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #79: Improve our requirements handling

2017-03-20 Thread AviaE
GitHub user AviaE opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/79

Improve our requirements handling

1. Currently, don't vendor any library.

2. Use pip-tools (specifically, pip-compile) to manage our dependencies
   requirement files.

3. requirements.in:
   The requirements.in will be read into `install_requires`, and includes
   loose dependencies (as possible, and only direct dependencies), as is
   common when installing using a setup.py file.
   Since we haven't tested ARIA with many versions of our dependencies, our
   dependencies are not very loose, but we are hoping to improve this as
   our project matures.
   Currently, when we provide an upper bound, it is either because of python
   2.6 compatibility, or according to a semantic versioning (i.e. future
   versions that could break the current API). Lower boundaries are
   usually the lowest version that we tested with ARIA, or because version
   before are lacking functionality we are using.

4. requirements.txt:
   The requirements.txt is generated from requirements.in via pip-compile,
   and includes fixed-version dependencies, including all transitive
   dependencies, in order to provide an stable environment that ARIA is
   ensured to work on.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-96-less-strict-dependencies

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/79.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #79


commit d7f32e1d64706fe074712d1bed0b38617d889d1e
Author: Avia Efrat <a...@gigaspaces.com>
Date:   2017-03-09T10:02:06Z

Improve our requirements handling

1. Currently, don't vendor any library.

2. Use pip-tools (specifically, pip-compile) to manage our dependencies
   requirement files.

3. requirements.in:
   The requirements.in will be read into `install_requires`, and includes
   loose dependencies (as possible, and only direct dependencies), as is
   common when installing using a setup.py file.
   Since we haven't tested ARIA with many versions of our dependencies, our
   dependencies are not very loose, but we are hoping to improve this as
   our project matures.
   Currently, when we provide an upper bound, it is either because of python
   2.6 compatibility, or according to a semantic versioning (i.e. future
   versions that could break the current API). Lower boundaries are
   usually the lowest version that we tested with ARIA, or because version
   before are lacking functionality we are using.

4. requirements.txt:
   The requirements.txt is generated from requirements.in via pip-compile,
   and includes fixed-version dependencies, including all transitive
   dependencies, in order to provide an stable environment that ARIA is
   ensured to work on.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---