Github user mxmrlv commented on a diff in the pull request:
https://github.com/apache/incubator-ariatosca/pull/31#discussion_r90778725
--- Diff: aria/storage/models.py ---
@@ -422,23 +531,55 @@ def validate_max_attempts(_, value, *args):
SUCCESS,
FAILED,
)
+
WAIT_STATES = [PENDING, RETRYING]
END_STATES = [SUCCESS, FAILED]
+
+ @validates('max_attempts')
+ def validate_max_attempts(self, _, value):
# pylint: disable=no-self-use
+ """Validates that max attempts is either -1 or a positive number"""
+ if value < 1 and value != Task.INFINITE_RETRIES:
+ raise ValueError('Max attempts can be either -1 (infinite) or
any positive number. '
+ 'Got {value}'.format(value=value))
+ return value
+
INFINITE_RETRIES = -1
- id = Field(type=basestring, default=uuid_generator)
- status = Field(type=basestring, choices=STATES, default=PENDING)
- execution_id = Field(type=basestring)
- due_at = Field(type=datetime, default=datetime.utcnow)
- started_at = Field(type=datetime, default=None)
- ended_at = Field(type=datetime, default=None)
- max_attempts = Field(type=int, default=1,
validation_func=_Validation.validate_max_attempts)
- retry_count = Field(type=int, default=0)
- retry_interval = Field(type=(int, float), default=0)
- ignore_failure = Field(type=bool, default=False)
+ status = Column(Enum(*STATES), name='status', default=PENDING)
+
+ execution_id = Column(String)
+ due_at = Column(DateTime, default=datetime.utcnow, nullable=True)
+ started_at = Column(DateTime, default=None, nullable=True)
+ ended_at = Column(DateTime, default=None, nullable=True)
+ max_attempts = Column(Integer, default=1)
+ retry_count = Column(Integer, default=0)
+ retry_interval = Column(Float, default=0)
+ ignore_failure = Column(Boolean, default=False)
# Operation specific fields
- name = Field(type=basestring)
- operation_mapping = Field(type=basestring)
- actor = Field()
- inputs = Field(type=dict, default=lambda: {})
+ name = Column(String)
+ operation_mapping = Column(String)
+ inputs = Column(MutableDict.as_mutable(Dict))
+
+ @property
+ def actor_storage_id(self):
--- 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 [email protected] or file a JIRA ticket
with INFRA.
---