Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
ARIA-155 Clean models from unused fields
  • Loading branch information
Ran Ziv committed Apr 30, 2017
1 parent 1f3e7ff commit d0c5e6fa1732a1b90992a7a75721b408f8a1b575
Showing 10 changed files with 77 additions and 111 deletions.
@@ -92,7 +92,6 @@ def validate_status(self, key, value):
started_at = Column(DateTime, nullable=True, index=True)
ended_at = Column(DateTime, nullable=True, index=True)
error = Column(Text, nullable=True)
is_system_workflow = Column(Boolean, nullable=False, default=False)
status = Column(Enum(*STATES, name='execution_status'), default=PENDING)
workflow_name = Column(Text)

@@ -252,8 +251,8 @@ class TaskBase(ModelMixin):
:vartype started_at: datetime
:ivar ended_at: Timestamp for when task ended
:vartype ended_at: datetime
:ivar retry_count: How many retries occurred
:vartype retry_count: int
:ivar attempts_count: How many attempts occurred
:vartype attempts_count: int
"""

__tablename__ = 'task'
@@ -314,7 +313,7 @@ def inputs(cls):
due_at = Column(DateTime, nullable=False, index=True, default=datetime.utcnow())
started_at = Column(DateTime, default=None)
ended_at = Column(DateTime, default=None)
retry_count = Column(Integer, default=0)
attempts_count = Column(Integer, default=1)

def has_ended(self):
return self.status in (self.SUCCESS, self.FAILED)
@@ -74,10 +74,6 @@ class ServiceBase(InstanceModelMixin):
:vartype created_at: :class:`datetime.datetime`
:ivar updated_at: Update timestamp
:vartype updated_at: :class:`datetime.datetime`
:ivar permalink: ??
:vartype permalink: basestring
:ivar scaling_groups: ??
:vartype scaling_groups: {}
:ivar modifications: Modifications of this service
:vartype modifications: [:class:`ServiceModification`]
:ivar updates: Updates of this service
@@ -187,13 +183,6 @@ def plugins(cls):
created_at = Column(DateTime, nullable=False, index=True)
updated_at = Column(DateTime)

# region orchestration

permalink = Column(Text)
scaling_groups = Column(modeling_types.Dict)

# endregion

def satisfy_requirements(self):
satisfied = True
for node in self.nodes.itervalues():
@@ -346,8 +335,6 @@ class NodeBase(InstanceModelMixin):
:vartype host: :class:`Node`
:ivar runtime_properties: TODO: should be replaced with attributes
:vartype runtime_properties: {}
:ivar scaling_groups: ??
:vartype scaling_groups: []
:ivar state: The state of the node, according to to the TOSCA-defined node states
:vartype state: string
:ivar version: Used by `aria.storage.instrumentation`
@@ -530,7 +517,6 @@ def properties(cls):

description = Column(Text)
runtime_properties = Column(modeling_types.Dict)
scaling_groups = Column(modeling_types.List)
state = Column(Enum(*STATES, name='node_state'), nullable=False, default=INITIAL)
version = Column(Integer, default=1)

@@ -1653,10 +1639,10 @@ class OperationBase(InstanceModelMixin):
:vartype dependencies: [basestring]
:ivar inputs: Parameters that can be used by this operation
:vartype inputs: {basestring: :class:`Parameter`}
:ivar executor: Executor name
:ivar executor: Name of executor to run the operation with
:vartype executor: basestring
:ivar max_retries: Maximum number of retries allowed in case of failure
:vartype max_retries: int
:ivar max_attempts: Maximum number of attempts allowed in case of failure
:vartype max_attempts: int
:ivar retry_interval: Interval between retries (in seconds)
:vartype retry_interval: int
:ivar interface: Containing interface
@@ -1742,7 +1728,7 @@ def inputs(cls):
configuration = Column(modeling_types.StrictDict(key_cls=basestring))
dependencies = Column(modeling_types.StrictList(item_cls=basestring))
executor = Column(Text)
max_retries = Column(Integer)
max_attempts = Column(Integer)
retry_interval = Column(Integer)

def configure(self):
@@ -1771,7 +1757,7 @@ def as_raw(self):
('implementation', self.implementation),
('dependencies', self.dependencies),
('executor', self.executor),
('max_retries', self.max_retries),
('max_attempts', self.max_attempts),
('retry_interval', self.retry_interval),
('inputs', formatting.as_raw_dict(self.inputs))))

@@ -1805,8 +1791,8 @@ def dump(self):
', '.join((str(context.style.literal(v)) for v in self.dependencies))))
if self.executor is not None:
console.puts('Executor: {0}'.format(context.style.literal(self.executor)))
if self.max_retries is not None:
console.puts('Max retries: {0}'.format(context.style.literal(self.max_retries)))
if self.max_attempts is not None:
console.puts('Max attempts: {0}'.format(context.style.literal(self.max_attempts)))
if self.retry_interval is not None:
console.puts('Retry interval: {0}'.format(
context.style.literal(self.retry_interval)))
@@ -1762,10 +1762,10 @@ class OperationTemplateBase(TemplateModelMixin):
:vartype dependencies: [basestring]
:ivar inputs: Parameters that can be used by this operation
:vartype inputs: {basestring: :class:`Parameter`}
:ivar executor: Executor name
:ivar executor: Name of executor to run the operation with
:vartype executor: basestring
:ivar max_retries: Maximum number of retries allowed in case of failure
:vartype max_retries: int
:ivar max_attempts: Maximum number of attempts allowed in case of failure
:vartype max_attempts: int
:ivar retry_interval: Interval between retries (in seconds)
:vartype retry_interval: int
:ivar interface_template: Containing interface template
@@ -1848,7 +1848,7 @@ def inputs(cls):
configuration = Column(modeling_types.StrictDict(key_cls=basestring))
dependencies = Column(modeling_types.StrictList(item_cls=basestring))
executor = Column(Text)
max_retries = Column(Integer)
max_attempts = Column(Integer)
retry_interval = Column(Integer)

@property
@@ -1859,7 +1859,7 @@ def as_raw(self):
('implementation', self.implementation),
('dependencies', self.dependencies),
('executor', self.executor),
('max_retries', self.max_retries),
('max_attempts', self.max_attempts),
('retry_interval', self.retry_interval),
('inputs', formatting.as_raw_dict(self.inputs))))

@@ -1889,7 +1889,7 @@ def instantiate(self, container):
configuration=self.configuration,
dependencies=self.dependencies,
executor=self.executor,
max_retries=self.max_retries,
max_attempts=self.max_attempts,
retry_interval=self.retry_interval,
operation_template=self)
utils.instantiate_dict(container, operation.inputs, self.inputs)
@@ -1923,8 +1923,8 @@ def dump(self):
', '.join((str(context.style.literal(v)) for v in self.dependencies))))
if self.executor is not None:
console.puts('Executor: {0}'.format(context.style.literal(self.executor)))
if self.max_retries is not None:
console.puts('Max retries: {0}'.format(context.style.literal(self.max_retries)))
if self.max_attempts is not None:
console.puts('Max attempts: {0}'.format(context.style.literal(self.max_attempts)))
if self.retry_interval is not None:
console.puts('Retry interval: {0}'.format(
context.style.literal(self.retry_interval)))
@@ -49,7 +49,7 @@ def _task_failed(task, exception, *args, **kwargs):
with task._update():
should_retry = all([
not isinstance(exception, exceptions.TaskAbortException),
task.retry_count < task.max_attempts - 1 or task.max_attempts == task.INFINITE_RETRIES,
task.attempts_count < task.max_attempts or task.max_attempts == task.INFINITE_RETRIES,
# ignore_failure check here means the task will not be retries and it will be marked
# as failed. The engine will also look at ignore_failure so it won't fail the
# workflow.
@@ -62,7 +62,7 @@ def _task_failed(task, exception, *args, **kwargs):
if retry_interval is None:
retry_interval = task.retry_interval
task.status = task.RETRYING
task.retry_count += 1
task.attempts_count += 1
task.due_at = datetime.utcnow() + timedelta(seconds=retry_interval)
else:
task.ended_at = datetime.utcnow()
@@ -229,17 +229,17 @@ def ended_at(self, value):
self._update_fields['ended_at'] = value

@property
def retry_count(self):
def attempts_count(self):
"""
Returns the retry count for the task
:return: retry count
Returns the attempts count for the task
:return: attempts count
"""
return self.model_task.retry_count
return self.model_task.attempts_count

@retry_count.setter
@attempts_count.setter
@_locked
def retry_count(self, value):
self._update_fields['retry_count'] = value
def attempts_count(self, value):
self._update_fields['attempts_count'] = value

@property
def due_at(self):
@@ -81,8 +81,6 @@ def create_service(service_template, name=SERVICE_NAME, inputs=None):
description='',
created_at=now,
updated_at=now,
permalink='',
scaling_groups={},
)


@@ -196,7 +194,6 @@ def create_node(dependency_node_template, service, name=NODE_NAME, state=models.
version=None,
node_template=dependency_node_template,
state=state,
scaling_groups=[],
service=service,
interfaces=get_standard_interface(service),
)
@@ -97,8 +97,6 @@ def test_model_to_dict(context):
expected_keys = [
'description',
'created_at',
'permalink',
'scaling_groups',
'updated_at'
]

@@ -128,7 +126,6 @@ def test_relationship_model_ordering(context):
version=None,
node_template=new_node_template,
state=modeling.models.Node.INITIAL,
scaling_groups=[]
)

source_node.outbound_relationships.append(modeling.models.Relationship(

0 comments on commit d0c5e6f

Please sign in to comment.