You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mxmrlv <gi...@git.apache.org> on 2016/12/13 16:09:07 UTC

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

GitHub user mxmrlv opened a pull request:

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

    Genericize-storage-models

    

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

    $ git pull https://github.com/apache/incubator-ariatosca ARIA-39-Genericize-storage-models

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

    https://github.com/apache/incubator-ariatosca/pull/33.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 #33
    
----
commit 68714fb1cfc5bc7a96b5bd89a3f02ce93828a1cf
Author: mxmrlv <mx...@gmail.com>
Date:   2016-12-11T22:50:09Z

    Generifying ARIA models

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93606793
  
    --- Diff: aria/orchestrator/workflows/builtin/heal.py ---
    @@ -163,10 +163,11 @@ def heal_install(ctx, graph, failing_node_instances, targeted_node_instances):
     
     
     def _get_contained_subgraph(context, host_node_instance):
    -    contained_instances = [node_instance
    -                           for node_instance in context.node_instances
    -                           if node_instance.host_id == host_node_instance.id and
    -                           node_instance.id != node_instance.host_id]
    +    contained_instances = [
    --- End diff --
    
    bug


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93606054
  
    --- Diff: aria/orchestrator/context/workflow.py ---
    @@ -86,9 +85,11 @@ def nodes(self):
             """
             Iterator over nodes
             """
    +        key = 'deployment_{0}'.format(self.model.node_instance.model_cls.name_column_name())
    --- End diff --
    
    name


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93609634
  
    --- Diff: aria/storage/structure.py ---
    @@ -0,0 +1,180 @@
    +# 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.
    +
    +"""
    +Aria's storage.structures module
    +Path: aria.storage.structures
    +
    +models module holds aria's models.
    +
    +classes:
    +    * Field - represents a single field.
    +    * IterField - represents an iterable field.
    +    * PointerField - represents a single pointer field.
    +    * IterPointerField - represents an iterable pointers field.
    +    * Model - abstract model implementation.
    +"""
    +
    +from sqlalchemy.orm import relationship, backref
    +from sqlalchemy.ext import associationproxy
    +from sqlalchemy import (
    +    Column,
    +    ForeignKey,
    +    Integer,
    +    Text
    +)
    +
    +
    +class ModelMixin(object):
    +
    +    @classmethod
    +    def id_column_name(cls):
    +        raise NotImplementedError
    +
    +    @classmethod
    +    def name_column_name(cls):
    +        raise NotImplementedError
    +
    +    @classmethod
    +    def _get_cls_by_tablename(cls, tablename):
    +        """Return class reference mapped to table.
    +
    +         :param tablename: String with name of table.
    +         :return: Class reference or None.
    +         """
    +        if tablename in (cls.__name__, cls.__tablename__):
    +            return cls
    +
    +        for table_cls in cls._decl_class_registry.values():
    +            if tablename in (getattr(table_cls, '__name__', None),
    +                             getattr(table_cls, '__tablename__', None)):
    +                return table_cls
    +
    +    @classmethod
    +    def foreign_key(cls, table, nullable=False):
    +        """Return a ForeignKey object with the relevant
    +
    +        :param table: Unique id column in the parent table
    +        :param nullable: Should the column be allowed to remain empty
    +        """
    +        table = cls._get_cls_by_tablename(table.__tablename__)
    +        foreign_key_str = '{tablename}.{unique_id}'.format(tablename=table.__tablename__,
    +                                                           unique_id=table.id_column_name())
    +        column = Column(ForeignKey(foreign_key_str, ondelete='CASCADE'),
    +                        nullable=nullable)
    +        column.__remote_table_name = table.__name__
    +        return column
    +
    +    @classmethod
    +    def one_to_many_relationship(cls,
    +                                 foreign_key_column,
    +                                 backreference=None):
    +        """Return a one-to-many SQL relationship object
    +        Meant to be used from inside the *child* object
    +
    +        :param parent_class: Class of the parent table
    +        :param cls: Class of the child table
    +        :param foreign_key_column: The column of the foreign key (from the child table)
    +        :param backreference: The name to give to the reference to the child (on the parent table)
    +        """
    +        parent_table = cls._get_cls_by_tablename(
    +            getattr(cls, foreign_key_column).__remote_table_name)
    +        primaryjoin_str = '{parent_class_name}.{parent_unique_id} == ' \
    +                          '{child_class.__name__}.{foreign_key_column}'\
    +            .format(
    +                parent_class_name=parent_table.__name__,
    +                parent_unique_id=parent_table.id_column_name(),
    +                child_class=cls,
    +                foreign_key_column=foreign_key_column
    +            )
    +        return relationship(
    +            parent_table.__name__,
    +            primaryjoin=primaryjoin_str,
    +            foreign_keys=[getattr(cls, foreign_key_column)],
    +            # The following line make sure that when the *parent* is
    +            # deleted, all its connected children are deleted as well
    +            backref=backref(backreference or cls.__tablename__, cascade='all'),
    +        )
    +
    +    @classmethod
    +    def relationship_to_self(cls, local_column):
    +
    +        remote_side_str = '{cls.__name__}.{remote_column}'.format(
    +            cls=cls,
    +            remote_column=cls.id_column_name()
    +        )
    +        primaryjoin_str = '{remote_side_str} == {cls.__name__}.{local_column}'.format(
    +            remote_side_str=remote_side_str,
    +            cls=cls,
    +            local_column=local_column)
    +        return relationship(cls.__name__,
    +                            primaryjoin=primaryjoin_str,
    +                            remote_side=remote_side_str,
    +                            post_update=True)
    +
    +    def to_dict(self, suppress_error=False):
    +        """Return a dict representation of the model
    +
    +        :param suppress_error: If set to True, sets `None` to attributes that
    +        it's unable to retrieve (e.g., if a relationship wasn't established
    +        yet, and so it's impossible to access a property through it)
    +        """
    +        if suppress_error:
    +            res = dict()
    +            for field in self.fields():
    +                try:
    +                    field_value = getattr(self, field)
    +                except AttributeError:
    +                    field_value = None
    +                res[field] = field_value
    +        else:
    +            # Can't simply call here `self.to_response()` because inheriting
    +            # class might override it, but we always need the same code here
    +            res = dict((f, getattr(self, f)) for f in self.fields())
    +        return res
    +
    +    @classmethod
    +    def _association_proxies(cls):
    +        for col, value in vars(cls).items():
    +            if isinstance(value, associationproxy.AssociationProxy):
    +                yield col
    +
    +    @classmethod
    +    def fields(cls):
    +        """Return the list of field names for this table
    +
    +        Mostly for backwards compatibility in the code (that uses `fields`)
    +        """
    +        fields = set(cls._association_proxies())
    +        fields.update(cls.__table__.columns.keys())
    +        return fields - set(cls._private_fields)
    --- End diff --
    
    add default


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93617348
  
    --- Diff: aria/storage/structure.py ---
    @@ -39,6 +39,8 @@
     
     class ModelMixin(object):
     
    +    # _private_fields = []
    --- End diff --
    
    restore


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93610626
  
    --- Diff: aria/storage/base_model.py ---
    @@ -110,20 +106,30 @@ class Deployment(SQLModelBase):
         policy_triggers = Column(Dict)
         policy_types = Column(Dict)
         outputs = Column(Dict)
    -    scaling_groups = Column(Dict)
    +    scaling_groups = Column(List)
         updated_at = Column(DateTime)
    -    workflows = Column(Dict)
    +    workflows = Column(List)
    +
    +    @declared_attr
    +    def blueprint_fk(cls):
    +        return cls.foreign_key(BlueprintBase, nullable=False)
     
         @declared_attr
         def blueprint(cls):
    -        return one_to_many_relationship(cls, Blueprint, cls.blueprint_id)
    +        return cls.one_to_many_relationship('blueprint_fk')
    --- End diff --
    
    consider `cls.blueprint_fk`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93617315
  
    --- Diff: aria/orchestrator/workflows/core/task.py ---
    @@ -135,7 +134,7 @@ def __init__(self, api_task, *args, **kwargs):
                 max_attempts=api_task.max_attempts,
                 retry_interval=api_task.retry_interval,
                 ignore_failure=api_task.ignore_failure,
    -            plugin_fk=plugin_id,
    +            plugin=plugins[0] if plugins else None,
    --- End diff --
    
    put back


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93608539
  
    --- Diff: aria/storage/structure.py ---
    @@ -0,0 +1,180 @@
    +# 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.
    +
    +"""
    +Aria's storage.structures module
    +Path: aria.storage.structures
    +
    +models module holds aria's models.
    +
    +classes:
    +    * Field - represents a single field.
    +    * IterField - represents an iterable field.
    +    * PointerField - represents a single pointer field.
    +    * IterPointerField - represents an iterable pointers field.
    +    * Model - abstract model implementation.
    +"""
    +
    +from sqlalchemy.orm import relationship, backref
    +from sqlalchemy.ext import associationproxy
    +from sqlalchemy import (
    +    Column,
    +    ForeignKey,
    +    Integer,
    +    Text
    +)
    +
    +
    +class ModelMixin(object):
    +
    +    @classmethod
    +    def id_column_name(cls):
    +        raise NotImplementedError
    +
    +    @classmethod
    +    def name_column_name(cls):
    +        raise NotImplementedError
    +
    +    @classmethod
    +    def _get_cls_by_tablename(cls, tablename):
    +        """Return class reference mapped to table.
    +
    +         :param tablename: String with name of table.
    +         :return: Class reference or None.
    +         """
    +        if tablename in (cls.__name__, cls.__tablename__):
    +            return cls
    +
    +        for table_cls in cls._decl_class_registry.values():
    +            if tablename in (getattr(table_cls, '__name__', None),
    +                             getattr(table_cls, '__tablename__', None)):
    +                return table_cls
    +
    +    @classmethod
    +    def foreign_key(cls, table, nullable=False):
    +        """Return a ForeignKey object with the relevant
    +
    +        :param table: Unique id column in the parent table
    +        :param nullable: Should the column be allowed to remain empty
    +        """
    +        table = cls._get_cls_by_tablename(table.__tablename__)
    --- End diff --
    
    table_cls


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by mxmrlv <gi...@git.apache.org>.
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93612551
  
    --- Diff: aria/storage/structure.py ---
    @@ -0,0 +1,180 @@
    +# 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.
    +
    +"""
    +Aria's storage.structures module
    +Path: aria.storage.structures
    +
    +models module holds aria's models.
    +
    +classes:
    +    * Field - represents a single field.
    +    * IterField - represents an iterable field.
    +    * PointerField - represents a single pointer field.
    +    * IterPointerField - represents an iterable pointers field.
    +    * Model - abstract model implementation.
    +"""
    +
    +from sqlalchemy.orm import relationship, backref
    +from sqlalchemy.ext import associationproxy
    +from sqlalchemy import (
    +    Column,
    +    ForeignKey,
    +    Integer,
    +    Text
    +)
    +
    +
    +class ModelMixin(object):
    +
    +    @classmethod
    +    def id_column_name(cls):
    +        raise NotImplementedError
    +
    +    @classmethod
    +    def name_column_name(cls):
    +        raise NotImplementedError
    +
    +    @classmethod
    +    def _get_cls_by_tablename(cls, tablename):
    +        """Return class reference mapped to table.
    +
    +         :param tablename: String with name of table.
    +         :return: Class reference or None.
    +         """
    +        if tablename in (cls.__name__, cls.__tablename__):
    +            return cls
    +
    +        for table_cls in cls._decl_class_registry.values():
    +            if tablename in (getattr(table_cls, '__name__', None),
    +                             getattr(table_cls, '__tablename__', None)):
    +                return table_cls
    +
    +    @classmethod
    +    def foreign_key(cls, table, nullable=False):
    +        """Return a ForeignKey object with the relevant
    +
    +        :param table: Unique id column in the parent table
    +        :param nullable: Should the column be allowed to remain empty
    +        """
    +        table = cls._get_cls_by_tablename(table.__tablename__)
    +        foreign_key_str = '{tablename}.{unique_id}'.format(tablename=table.__tablename__,
    +                                                           unique_id=table.id_column_name())
    +        column = Column(ForeignKey(foreign_key_str, ondelete='CASCADE'),
    +                        nullable=nullable)
    +        column.__remote_table_name = table.__name__
    +        return column
    +
    +    @classmethod
    +    def one_to_many_relationship(cls,
    +                                 foreign_key_column,
    +                                 backreference=None):
    +        """Return a one-to-many SQL relationship object
    +        Meant to be used from inside the *child* object
    +
    +        :param parent_class: Class of the parent table
    +        :param cls: Class of the child table
    +        :param foreign_key_column: The column of the foreign key (from the child table)
    +        :param backreference: The name to give to the reference to the child (on the parent table)
    +        """
    +        parent_table = cls._get_cls_by_tablename(
    +            getattr(cls, foreign_key_column).__remote_table_name)
    +        primaryjoin_str = '{parent_class_name}.{parent_unique_id} == ' \
    +                          '{child_class.__name__}.{foreign_key_column}'\
    +            .format(
    +                parent_class_name=parent_table.__name__,
    +                parent_unique_id=parent_table.id_column_name(),
    +                child_class=cls,
    +                foreign_key_column=foreign_key_column
    +            )
    +        return relationship(
    +            parent_table.__name__,
    +            primaryjoin=primaryjoin_str,
    +            foreign_keys=[getattr(cls, foreign_key_column)],
    +            # The following line make sure that when the *parent* is
    +            # deleted, all its connected children are deleted as well
    +            backref=backref(backreference or cls.__tablename__, cascade='all'),
    +        )
    +
    +    @classmethod
    +    def relationship_to_self(cls, local_column):
    +
    +        remote_side_str = '{cls.__name__}.{remote_column}'.format(
    +            cls=cls,
    +            remote_column=cls.id_column_name()
    +        )
    +        primaryjoin_str = '{remote_side_str} == {cls.__name__}.{local_column}'.format(
    +            remote_side_str=remote_side_str,
    +            cls=cls,
    +            local_column=local_column)
    +        return relationship(cls.__name__,
    +                            primaryjoin=primaryjoin_str,
    +                            remote_side=remote_side_str,
    +                            post_update=True)
    +
    +    def to_dict(self, suppress_error=False):
    +        """Return a dict representation of the model
    +
    +        :param suppress_error: If set to True, sets `None` to attributes that
    +        it's unable to retrieve (e.g., if a relationship wasn't established
    +        yet, and so it's impossible to access a property through it)
    +        """
    +        if suppress_error:
    +            res = dict()
    +            for field in self.fields():
    +                try:
    +                    field_value = getattr(self, field)
    +                except AttributeError:
    +                    field_value = None
    +                res[field] = field_value
    +        else:
    +            # Can't simply call here `self.to_response()` because inheriting
    +            # class might override it, but we always need the same code here
    +            res = dict((f, getattr(self, f)) for f in self.fields())
    +        return res
    +
    +    @classmethod
    +    def _association_proxies(cls):
    +        for col, value in vars(cls).items():
    +            if isinstance(value, associationproxy.AssociationProxy):
    +                yield col
    +
    +    @classmethod
    +    def fields(cls):
    +        """Return the list of field names for this table
    +
    +        Mostly for backwards compatibility in the code (that uses `fields`)
    +        """
    +        fields = set(cls._association_proxies())
    +        fields.update(cls.__table__.columns.keys())
    +        return fields - set(cls._private_fields)
    --- End diff --
    
    added


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93606447
  
    --- Diff: aria/orchestrator/context/workflow.py ---
    @@ -86,9 +85,11 @@ def nodes(self):
             """
             Iterator over nodes
             """
    +        key = 'deployment_{0}'.format(self.model.node_instance.model_cls.name_column_name())
    --- End diff --
    
    should be node not node instance


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93606958
  
    --- Diff: aria/orchestrator/workflows/core/task.py ---
    @@ -106,36 +106,37 @@ class OperationTask(BaseTask):
         def __init__(self, api_task, *args, **kwargs):
             super(OperationTask, self).__init__(id=api_task.id, **kwargs)
             self._workflow_context = api_task._workflow_context
    -        model = api_task._workflow_context.model
    +        model_storage = api_task._workflow_context.model
     
    -        base_task_model = model.task.model_cls
    -        if isinstance(api_task.actor, models.NodeInstance):
    +        base_task_model = model_storage.task.model_cls
    +        if isinstance(api_task.actor, model.NodeInstance):
                 context_class = operation_context.NodeOperationContext
                 task_model_cls = base_task_model.as_node_instance
    -        elif isinstance(api_task.actor, models.RelationshipInstance):
    +        elif isinstance(api_task.actor, model.RelationshipInstance):
                 context_class = operation_context.RelationshipOperationContext
                 task_model_cls = base_task_model.as_relationship_instance
             else:
                 raise RuntimeError('No operation context could be created for {actor.model_cls}'
                                    .format(actor=api_task.actor))
             plugin = api_task.plugin
    -        plugins = model.plugin.list(filters={'package_name': plugin.get('package_name', ''),
    -                                             'package_version': plugin.get('package_version', '')},
    -                                    include=['id'])
    +        plugins = model_storage.plugin.list(filters={
    +            'package_name': plugin.get('package_name', ''),
    +            'package_version': plugin.get('package_version', '')
    +        }, include=['id'])
             # Validation during installation ensures that at most one plugin can exists with provided
             # package_name and package_version
             plugin_id = plugins[0].id if plugins else None
             operation_task = task_model_cls(
                 name=api_task.name,
                 operation_mapping=api_task.operation_mapping,
    -            instance_id=api_task.actor.id,
    +            instance=api_task.actor,
                 inputs=api_task.inputs,
                 status=base_task_model.PENDING,
                 max_attempts=api_task.max_attempts,
                 retry_interval=api_task.retry_interval,
                 ignore_failure=api_task.ignore_failure,
    -            plugin_id=plugin_id,
    -            execution_id=self._workflow_context.execution.id
    +            plugin_fk=plugin_id,
    --- End diff --
    
    fk


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93611278
  
    --- Diff: aria/storage/base_model.py ---
    @@ -545,31 +657,21 @@ def validate_max_attempts(self, _, value):                                  # py
         ignore_failure = Column(Boolean, default=False)
     
         # Operation specific fields
    -    name = Column(String)
         operation_mapping = Column(String)
         inputs = Column(Dict)
    -    plugin_id = foreign_key(Plugin.id, nullable=True)
    -
    -    @declared_attr
    -    def plugin(cls):
    -        return one_to_many_relationship(cls, Plugin, cls.plugin_id)
    -
    -    @declared_attr
    -    def execution(cls):
    -        return one_to_many_relationship(cls, Execution, cls.execution_id)
     
         @property
         def actor(self):
             """
             Return the actor of the task
             :return:
    -        """
    +      `  """
    --- End diff --
    
    what is this?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #33: Genericize-storage-models

Posted by dankilman <gi...@git.apache.org>.
Github user dankilman commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/33#discussion_r93606315
  
    --- Diff: aria/orchestrator/context/workflow.py ---
    @@ -86,9 +85,11 @@ def nodes(self):
             """
             Iterator over nodes
             """
    +        key = 'deployment_{0}'.format(self.model.node_instance.model_cls.name_column_name())
    +
             return self.model.node.iter(
                 filters={
    -                'deployment_id': self.deployment.id
    +                key: getattr(self.deployment, self.deployment.name_column_name())
    --- End diff --
    
    simplify?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---