incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-284-Cleanup-and-optimize-the-task-execution 814306ba0 -> c211e1064 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/c211e106 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c211e106 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c211e106 Branch: refs/heads/ARIA-284-Cleanup-and-optimize-the-task-execution Commit: c211e1064fc84236ef753783fb4367d335ab197a Parents: 1fee85c Author: max-orlovAuthored: Wed Jun 21 12:41:33 2017 +0300 Committer: max-orlov Committed: Wed Jun 21 14:00:41 2017 +0300 -- aria/modeling/orchestration.py | 2 - aria/orchestrator/workflow_runner.py| 3 +- aria/orchestrator/workflows/core/compile.py | 198 ++- tests/orchestrator/context/__init__.py | 2 +- tests/orchestrator/context/test_serialize.py| 2 +- .../orchestrator/execution_plugin/test_local.py | 2 +- tests/orchestrator/execution_plugin/test_ssh.py | 3 +- .../orchestrator/workflows/core/test_engine.py | 2 +- .../orchestrator/workflows/core/test_events.py | 7 +- .../test_task_graph_into_execution_graph.py | 6 +- .../executor/test_process_executor_extension.py | 2 +- .../test_process_executor_tracked_changes.py| 2 +- 12 files changed, 116 insertions(+), 115 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c211e106/aria/modeling/orchestration.py -- diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py index 17d2476..541f4c4 100644 --- a/aria/modeling/orchestration.py +++ b/aria/modeling/orchestration.py @@ -305,7 +305,6 @@ class TaskBase(mixins.ModelMixin): ended_at = Column(DateTime, default=None) attempts_count = Column(Integer, default=1) -_api_id = Column(String) _executor = Column(PickleType) _context_cls = Column(PickleType) _stub_type = Column(Enum(*STUB_TYPES)) @@ -441,7 +440,6 @@ class TaskBase(mixins.ModelMixin): 'plugin': api_task.plugin, 'function': api_task.function, 'arguments': api_task.arguments, -'_api_id': api_task.id, '_context_cls': api_task._context_cls, '_executor': executor, } http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c211e106/aria/orchestrator/workflow_runner.py -- diff --git a/aria/orchestrator/workflow_runner.py b/aria/orchestrator/workflow_runner.py index 9e6b3ad..dcd8ce3 100644 --- a/aria/orchestrator/workflow_runner.py +++ b/aria/orchestrator/workflow_runner.py @@ -87,8 +87,7 @@ class WorkflowRunner(object): execution_inputs_dict = dict(inp.unwrapped for inp in self.execution.inputs.values()) self._tasks_graph = workflow_fn(ctx=self._workflow_context, **execution_inputs_dict) -compile.create_execution_tasks( -self._workflow_context, self._tasks_graph, executor.__class__) +compile.GraphCompiler(self._workflow_context, executor.__class__).compile(self._tasks_graph) self._engine = engine.Engine(executors={executor.__class__: executor}) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c211e106/aria/orchestrator/workflows/core/compile.py -- diff --git a/aria/orchestrator/workflows/core/compile.py b/aria/orchestrator/workflows/core/compile.py index 932268a..83de22c 100644 --- a/aria/orchestrator/workflows/core/compile.py +++ b/aria/orchestrator/workflows/core/compile.py @@ -18,99 +18,105 @@ from modeling import models from .. import executor, api -def create_execution_tasks(ctx, task_graph, default_executor): -execution = ctx.execution -_construct_execution_tasks(execution, task_graph, default_executor) -ctx.model.execution.update(execution) -return execution.tasks - - -def _construct_execution_tasks(execution, - task_graph, - default_executor, - stub_executor=executor.base.StubTaskExecutor, - start_stub_type=models.Task.START_WORKFLOW, - end_stub_type=models.Task.END_WORKFLOW, - depends_on=()): -""" -Translates the user graph to the execution graph -:param task_graph: The user's graph -:param start_stub_type: internal use -:param end_stub_type: internal use -:param
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-236-Resumable-workflow-executions 58de7a5ef -> 2fc9896cf (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/2fc9896c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/2fc9896c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/2fc9896c Branch: refs/heads/ARIA-236-Resumable-workflow-executions Commit: 2fc9896cfdd7e6528e19b8bc418d4e4413e595ed Parents: 1fee85c Author: max-orlovAuthored: Mon Jun 19 17:44:45 2017 +0300 Committer: max-orlov Committed: Wed Jun 21 12:02:52 2017 +0300 -- aria/cli/commands/executions.py | 58 ++- aria/cli/logger.py | 4 +- aria/modeling/orchestration.py | 3 +- aria/orchestrator/context/workflow.py | 5 + aria/orchestrator/events.py | 1 + aria/orchestrator/exceptions.py | 7 + aria/orchestrator/workflow_runner.py| 40 +++-- aria/orchestrator/workflows/core/engine.py | 4 + .../workflows/core/events_handler.py| 7 + tests/mock/__init__.py | 2 +- tests/mock/models.py| 14 +- tests/modeling/test_models.py | 5 +- tests/orchestrator/test_workflow_runner.py | 157 +-- 13 files changed, 263 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/2fc9896c/aria/cli/commands/executions.py -- diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py index 6176ea2..a6f06c3 100644 --- a/aria/cli/commands/executions.py +++ b/aria/cli/commands/executions.py @@ -134,18 +134,64 @@ def start(workflow_name, executor = DryExecutor() if dry else None # use WorkflowRunner's default executor workflow_runner = \ -WorkflowRunner(workflow_name, service.id, inputs, - model_storage, resource_storage, plugin_manager, - executor, task_max_attempts, task_retry_interval) +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +service_id=service.id, workflow_name=workflow_name, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) +logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if dry else '')) + +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + -execution_thread_name = '{0}_{1}'.format(service_name, workflow_name) +@executions.command(name='resume', +short_help='Resume a workflow') +@aria.argument('execution-id') +@aria.options.inputs(help=helptexts.EXECUTION_INPUTS) +@aria.options.dry_execution +@aria.options.task_max_attempts() +@aria.options.task_retry_interval() +@aria.options.mark_pattern() +@aria.options.verbose() +@aria.pass_model_storage +@aria.pass_resource_storage +@aria.pass_plugin_manager +@aria.pass_logger +def resume(execution_id, + inputs, + dry, + task_max_attempts, + task_retry_interval, + mark_pattern, + model_storage, + resource_storage, + plugin_manager, + logger): +executor = DryExecutor() if dry else None # use WorkflowRunner's default executor + +workflow_runner = \ +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +execution_id=execution_id, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) + +logger.info('Resuming {0}execution. Press Ctrl+C cancel'.format('dry ' if dry else '')) +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + + +def _run_execution(workflow_runner, logger, model_storage, dry, mark_pattern): +execution_thread_name = '{0}_{1}'.format(workflow_runner.service.name, + workflow_runner.execution.workflow_name) execution_thread = threading.ExceptionThread(target=workflow_runner.execute, name=execution_thread_name) -logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if dry else '')) execution_thread.start() -log_iterator = cli_logger.ModelLogIterator(model_storage, workflow_runner.execution_id) +last_task_id = workflow_runner.execution.logs[-1].id if workflow_runner.execution.logs else 0 +log_iterator =
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-236-Resumable-workflow-executions 82f188a02 -> 58de7a5ef (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/58de7a5e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/58de7a5e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/58de7a5e Branch: refs/heads/ARIA-236-Resumable-workflow-executions Commit: 58de7a5ef64b275eaed4ab33ec9ff6d311f5de8e Parents: 1fee85c Author: max-orlovAuthored: Mon Jun 19 17:44:45 2017 +0300 Committer: max-orlov Committed: Wed Jun 21 11:20:19 2017 +0300 -- aria/cli/commands/executions.py | 58 ++- aria/cli/logger.py | 4 +- aria/modeling/orchestration.py | 3 +- aria/orchestrator/context/workflow.py | 5 + aria/orchestrator/events.py | 1 + aria/orchestrator/exceptions.py | 7 + aria/orchestrator/workflow_runner.py| 40 +++-- aria/orchestrator/workflows/core/engine.py | 4 + .../workflows/core/events_handler.py| 7 + tests/mock/__init__.py | 2 +- tests/mock/models.py| 14 +- tests/modeling/test_models.py | 5 +- tests/orchestrator/test_workflow_runner.py | 157 +-- 13 files changed, 263 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/58de7a5e/aria/cli/commands/executions.py -- diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py index 6176ea2..a6f06c3 100644 --- a/aria/cli/commands/executions.py +++ b/aria/cli/commands/executions.py @@ -134,18 +134,64 @@ def start(workflow_name, executor = DryExecutor() if dry else None # use WorkflowRunner's default executor workflow_runner = \ -WorkflowRunner(workflow_name, service.id, inputs, - model_storage, resource_storage, plugin_manager, - executor, task_max_attempts, task_retry_interval) +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +service_id=service.id, workflow_name=workflow_name, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) +logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if dry else '')) + +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + -execution_thread_name = '{0}_{1}'.format(service_name, workflow_name) +@executions.command(name='resume', +short_help='Resume a workflow') +@aria.argument('execution-id') +@aria.options.inputs(help=helptexts.EXECUTION_INPUTS) +@aria.options.dry_execution +@aria.options.task_max_attempts() +@aria.options.task_retry_interval() +@aria.options.mark_pattern() +@aria.options.verbose() +@aria.pass_model_storage +@aria.pass_resource_storage +@aria.pass_plugin_manager +@aria.pass_logger +def resume(execution_id, + inputs, + dry, + task_max_attempts, + task_retry_interval, + mark_pattern, + model_storage, + resource_storage, + plugin_manager, + logger): +executor = DryExecutor() if dry else None # use WorkflowRunner's default executor + +workflow_runner = \ +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +execution_id=execution_id, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) + +logger.info('Resuming {0}execution. Press Ctrl+C cancel'.format('dry ' if dry else '')) +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + + +def _run_execution(workflow_runner, logger, model_storage, dry, mark_pattern): +execution_thread_name = '{0}_{1}'.format(workflow_runner.service.name, + workflow_runner.execution.workflow_name) execution_thread = threading.ExceptionThread(target=workflow_runner.execute, name=execution_thread_name) -logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if dry else '')) execution_thread.start() -log_iterator = cli_logger.ModelLogIterator(model_storage, workflow_runner.execution_id) +last_task_id = workflow_runner.execution.logs[-1].id if workflow_runner.execution.logs else 0 +log_iterator =
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-236-Resumable-workflow-executions 3ba6448b9 -> 82f188a02 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/82f188a0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/82f188a0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/82f188a0 Branch: refs/heads/ARIA-236-Resumable-workflow-executions Commit: 82f188a02d58e00802c4fcb683b0be048291282f Parents: 1fee85c Author: max-orlovAuthored: Mon Jun 19 17:44:45 2017 +0300 Committer: max-orlov Committed: Wed Jun 21 11:05:05 2017 +0300 -- aria/cli/commands/executions.py | 55 ++- aria/cli/logger.py | 4 +- aria/modeling/orchestration.py | 3 +- aria/orchestrator/context/workflow.py | 5 + aria/orchestrator/events.py | 1 + aria/orchestrator/exceptions.py | 7 + aria/orchestrator/workflow_runner.py| 40 +++-- aria/orchestrator/workflows/core/engine.py | 4 + .../workflows/core/events_handler.py| 7 + tests/mock/__init__.py | 2 +- tests/mock/models.py| 14 +- tests/modeling/test_models.py | 5 +- tests/orchestrator/test_workflow_runner.py | 157 +-- 13 files changed, 261 insertions(+), 43 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/82f188a0/aria/cli/commands/executions.py -- diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py index 6176ea2..f2f8221 100644 --- a/aria/cli/commands/executions.py +++ b/aria/cli/commands/executions.py @@ -134,18 +134,63 @@ def start(workflow_name, executor = DryExecutor() if dry else None # use WorkflowRunner's default executor workflow_runner = \ -WorkflowRunner(workflow_name, service.id, inputs, - model_storage, resource_storage, plugin_manager, - executor, task_max_attempts, task_retry_interval) +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +service_id=service.id, workflow_name=workflow_name, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) -execution_thread_name = '{0}_{1}'.format(service_name, workflow_name) +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + + +@executions.command(name='resume', +short_help='Resume a workflow') +@aria.argument('execution-id') +@aria.options.inputs(help=helptexts.EXECUTION_INPUTS) +@aria.options.dry_execution +@aria.options.task_max_attempts() +@aria.options.task_retry_interval() +@aria.options.mark_pattern() +@aria.options.verbose() +@aria.pass_model_storage +@aria.pass_resource_storage +@aria.pass_plugin_manager +@aria.pass_logger +def resume(execution_id, + inputs, + dry, + task_max_attempts, + task_retry_interval, + mark_pattern, + model_storage, + resource_storage, + plugin_manager, + logger): +executor = DryExecutor() if dry else None # use WorkflowRunner's default executor + +workflow_runner = \ +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +execution_id=execution_id, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) + +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + + +def _run_execution(workflow_runner, logger, model_storage, dry, mark_pattern): +execution_thread_name = '{0}_{1}'.format(workflow_runner.service.name, + workflow_runner.execution.workflow_name) execution_thread = threading.ExceptionThread(target=workflow_runner.execute, name=execution_thread_name) logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if dry else '')) execution_thread.start() -log_iterator = cli_logger.ModelLogIterator(model_storage, workflow_runner.execution_id) +last_task_id = workflow_runner.execution.logs[-1].id if workflow_runner.execution.logs else 0 +log_iterator = cli_logger.ModelLogIterator(model_storage, + workflow_runner.execution_id, + offset=last_task_id) try:
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-236-Resumable-workflow-executions 8fdea04ff -> 3ba6448b9 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/3ba6448b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/3ba6448b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/3ba6448b Branch: refs/heads/ARIA-236-Resumable-workflow-executions Commit: 3ba6448b9da8f8eff5d1bf3c97cd2b54961cc430 Parents: 1fee85c Author: max-orlovAuthored: Mon Jun 19 17:44:45 2017 +0300 Committer: max-orlov Committed: Wed Jun 21 10:57:20 2017 +0300 -- aria/cli/commands/executions.py | 55 ++- aria/cli/logger.py | 4 +- aria/modeling/orchestration.py | 3 +- aria/orchestrator/context/workflow.py | 5 + aria/orchestrator/events.py | 1 + aria/orchestrator/exceptions.py | 7 + aria/orchestrator/workflow_runner.py| 40 +++-- aria/orchestrator/workflows/core/engine.py | 4 + .../workflows/core/events_handler.py| 7 + tests/mock/__init__.py | 2 +- tests/mock/models.py| 14 +- tests/modeling/test_models.py | 5 +- tests/orchestrator/test_workflow_runner.py | 157 +-- 13 files changed, 261 insertions(+), 43 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3ba6448b/aria/cli/commands/executions.py -- diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py index 6176ea2..f2f8221 100644 --- a/aria/cli/commands/executions.py +++ b/aria/cli/commands/executions.py @@ -134,18 +134,63 @@ def start(workflow_name, executor = DryExecutor() if dry else None # use WorkflowRunner's default executor workflow_runner = \ -WorkflowRunner(workflow_name, service.id, inputs, - model_storage, resource_storage, plugin_manager, - executor, task_max_attempts, task_retry_interval) +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +service_id=service.id, workflow_name=workflow_name, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) -execution_thread_name = '{0}_{1}'.format(service_name, workflow_name) +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + + +@executions.command(name='resume', +short_help='Resume a workflow') +@aria.argument('execution-id') +@aria.options.inputs(help=helptexts.EXECUTION_INPUTS) +@aria.options.dry_execution +@aria.options.task_max_attempts() +@aria.options.task_retry_interval() +@aria.options.mark_pattern() +@aria.options.verbose() +@aria.pass_model_storage +@aria.pass_resource_storage +@aria.pass_plugin_manager +@aria.pass_logger +def resume(execution_id, + inputs, + dry, + task_max_attempts, + task_retry_interval, + mark_pattern, + model_storage, + resource_storage, + plugin_manager, + logger): +executor = DryExecutor() if dry else None # use WorkflowRunner's default executor + +workflow_runner = \ +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +execution_id=execution_id, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) + +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + + +def _run_execution(workflow_runner, logger, model_storage, dry, mark_pattern): +execution_thread_name = '{0}_{1}'.format(workflow_runner.service.name, + workflow_runner.execution.workflow_name) execution_thread = threading.ExceptionThread(target=workflow_runner.execute, name=execution_thread_name) logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if dry else '')) execution_thread.start() -log_iterator = cli_logger.ModelLogIterator(model_storage, workflow_runner.execution_id) +last_task_id = workflow_runner.execution.logs[-1].id if workflow_runner.execution.logs else 0 +log_iterator = cli_logger.ModelLogIterator(model_storage, + workflow_runner.execution_id, + offset=last_task_id) try:
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-236-Resumable-workflow-executions b17c04f81 -> c6f131e5f (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/c6f131e5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c6f131e5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c6f131e5 Branch: refs/heads/ARIA-236-Resumable-workflow-executions Commit: c6f131e5f434b0928cba2a9c3cb021b158216b54 Parents: 507796e Author: max-orlovAuthored: Mon Jun 19 17:44:45 2017 +0300 Committer: max-orlov Committed: Tue Jun 20 19:23:25 2017 +0300 -- aria/cli/commands/executions.py | 55 ++- aria/cli/logger.py | 4 +- aria/modeling/orchestration.py | 3 +- aria/orchestrator/context/workflow.py | 5 + aria/orchestrator/events.py | 1 + aria/orchestrator/exceptions.py | 7 + aria/orchestrator/workflow_runner.py| 41 +++-- aria/orchestrator/workflows/core/engine.py | 4 + .../workflows/core/events_handler.py| 7 + tests/mock/__init__.py | 2 +- tests/mock/models.py| 14 +- tests/modeling/test_models.py | 5 +- tests/orchestrator/test_workflow_runner.py | 157 +-- 13 files changed, 262 insertions(+), 43 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c6f131e5/aria/cli/commands/executions.py -- diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py index 6176ea2..f2f8221 100644 --- a/aria/cli/commands/executions.py +++ b/aria/cli/commands/executions.py @@ -134,18 +134,63 @@ def start(workflow_name, executor = DryExecutor() if dry else None # use WorkflowRunner's default executor workflow_runner = \ -WorkflowRunner(workflow_name, service.id, inputs, - model_storage, resource_storage, plugin_manager, - executor, task_max_attempts, task_retry_interval) +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +service_id=service.id, workflow_name=workflow_name, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) -execution_thread_name = '{0}_{1}'.format(service_name, workflow_name) +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + + +@executions.command(name='resume', +short_help='Resume a workflow') +@aria.argument('execution-id') +@aria.options.inputs(help=helptexts.EXECUTION_INPUTS) +@aria.options.dry_execution +@aria.options.task_max_attempts() +@aria.options.task_retry_interval() +@aria.options.mark_pattern() +@aria.options.verbose() +@aria.pass_model_storage +@aria.pass_resource_storage +@aria.pass_plugin_manager +@aria.pass_logger +def resume(execution_id, + inputs, + dry, + task_max_attempts, + task_retry_interval, + mark_pattern, + model_storage, + resource_storage, + plugin_manager, + logger): +executor = DryExecutor() if dry else None # use WorkflowRunner's default executor + +workflow_runner = \ +WorkflowRunner( +inputs, model_storage, resource_storage, plugin_manager, +execution_id=execution_id, executor=executor, +task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval +) + +_run_execution(workflow_runner, logger, model_storage, dry, mark_pattern) + + +def _run_execution(workflow_runner, logger, model_storage, dry, mark_pattern): +execution_thread_name = '{0}_{1}'.format(workflow_runner.service.name, + workflow_runner.execution.workflow_name) execution_thread = threading.ExceptionThread(target=workflow_runner.execute, name=execution_thread_name) logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if dry else '')) execution_thread.start() -log_iterator = cli_logger.ModelLogIterator(model_storage, workflow_runner.execution_id) +last_task_id = workflow_runner.execution.logs[-1].id if workflow_runner.execution.logs else 0 +log_iterator = cli_logger.ModelLogIterator(model_storage, + workflow_runner.execution_id, + offset=last_task_id) try:
[1/2] incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-278-Remove-core-tasks ee0ff3ac6 -> bfae4f39c (forced update) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/bfae4f39/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py -- diff --git a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py index 5dd2855..569e8be 100644 --- a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py +++ b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py @@ -13,12 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from networkx import topological_sort, DiGraph +from networkx import topological_sort +from aria.modeling import models from aria.orchestrator import context -from aria.orchestrator.workflows import api, core +from aria.orchestrator.workflows import ( +api, +core +) from aria.orchestrator.workflows.executor import base - from tests import mock from tests import storage @@ -26,8 +29,8 @@ from tests import storage def test_task_graph_into_execution_graph(tmpdir): interface_name = 'Standard' operation_name = 'create' -task_context = mock.context.simple(str(tmpdir)) -node = task_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) +workflow_context = mock.context.simple(str(tmpdir)) +node = workflow_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) interface = mock.models.create_interface( node.service, interface_name, @@ -35,12 +38,12 @@ def test_task_graph_into_execution_graph(tmpdir): operation_kwargs=dict(function='test') ) node.interfaces[interface.name] = interface -task_context.model.node.update(node) +workflow_context.model.node.update(node) def sub_workflow(name, **_): return api.task_graph.TaskGraph(name) -with context.workflow.current.push(task_context): +with context.workflow.current.push(workflow_context): test_task_graph = api.task.WorkflowTask(sub_workflow, name='test_task_graph') simple_before_task = api.task.OperationTask( node, @@ -65,11 +68,12 @@ def test_task_graph_into_execution_graph(tmpdir): test_task_graph.add_dependency(simple_after_task, inner_task_graph) # Direct check -execution_graph = DiGraph() -core.translation.build_execution_graph(task_graph=test_task_graph, - execution_graph=execution_graph, - default_executor=base.StubTaskExecutor()) -execution_tasks = topological_sort(execution_graph) +execution = workflow_context.model.execution.list()[0] + +core.engine.construct_execution_tasks(execution, test_task_graph, base.StubTaskExecutor) +workflow_context.execution = execution + +execution_tasks = topological_sort(workflow_context._graph) assert len(execution_tasks) == 7 @@ -83,30 +87,23 @@ def test_task_graph_into_execution_graph(tmpdir): '{0}-End'.format(test_task_graph.id) ] -assert expected_tasks_names == execution_tasks - -assert isinstance(_get_task_by_name(execution_tasks[0], execution_graph), - core.task.StartWorkflowTask) - -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[1], execution_graph), - simple_before_task) -assert isinstance(_get_task_by_name(execution_tasks[2], execution_graph), - core.task.StartSubWorkflowTask) +assert expected_tasks_names == [t.api_id for t in execution_tasks] +assert all(isinstance(task, models.Task) for task in execution_tasks) +execution_tasks = iter(execution_tasks) -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[3], execution_graph), - inner_task) -assert isinstance(_get_task_by_name(execution_tasks[4], execution_graph), - core.task.EndSubWorkflowTask) +assert next(execution_tasks).stub_type == models.Task.START_WORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_before_task) +assert next(execution_tasks).stub_type == models.Task.START_SUBWROFKLOW +_assert_execution_is_api_task(next(execution_tasks), inner_task) +assert next(execution_tasks).stub_type == models.Task.END_SUBWORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_after_task) +assert next(execution_tasks).stub_type == models.Task.END_WORKFLOW -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[5], execution_graph), - simple_after_task) -assert isinstance(_get_task_by_name(execution_tasks[6], execution_graph), -
[1/2] incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-278-Remove-core-tasks 25427ae59 -> b314f388b (forced update) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b314f388/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py -- diff --git a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py index 5dd2855..de40fcf 100644 --- a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py +++ b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py @@ -13,12 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from networkx import topological_sort, DiGraph - -from aria.orchestrator import context -from aria.orchestrator.workflows import api, core +from networkx import topological_sort + +from aria.modeling import models +from aria.orchestrator import ( +context, +workflow_runner +) +from aria.orchestrator.workflows import api from aria.orchestrator.workflows.executor import base - from tests import mock from tests import storage @@ -26,8 +29,8 @@ from tests import storage def test_task_graph_into_execution_graph(tmpdir): interface_name = 'Standard' operation_name = 'create' -task_context = mock.context.simple(str(tmpdir)) -node = task_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) +workflow_context = mock.context.simple(str(tmpdir)) +node = workflow_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) interface = mock.models.create_interface( node.service, interface_name, @@ -35,12 +38,12 @@ def test_task_graph_into_execution_graph(tmpdir): operation_kwargs=dict(function='test') ) node.interfaces[interface.name] = interface -task_context.model.node.update(node) +workflow_context.model.node.update(node) def sub_workflow(name, **_): return api.task_graph.TaskGraph(name) -with context.workflow.current.push(task_context): +with context.workflow.current.push(workflow_context): test_task_graph = api.task.WorkflowTask(sub_workflow, name='test_task_graph') simple_before_task = api.task.OperationTask( node, @@ -65,11 +68,12 @@ def test_task_graph_into_execution_graph(tmpdir): test_task_graph.add_dependency(simple_after_task, inner_task_graph) # Direct check -execution_graph = DiGraph() -core.translation.build_execution_graph(task_graph=test_task_graph, - execution_graph=execution_graph, - default_executor=base.StubTaskExecutor()) -execution_tasks = topological_sort(execution_graph) +execution = workflow_context.model.execution.list()[0] + +workflow_runner.construct_execution_tasks(execution, test_task_graph, base.StubTaskExecutor) +workflow_context.execution = execution + +execution_tasks = topological_sort(workflow_context._graph) assert len(execution_tasks) == 7 @@ -83,30 +87,23 @@ def test_task_graph_into_execution_graph(tmpdir): '{0}-End'.format(test_task_graph.id) ] -assert expected_tasks_names == execution_tasks - -assert isinstance(_get_task_by_name(execution_tasks[0], execution_graph), - core.task.StartWorkflowTask) - -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[1], execution_graph), - simple_before_task) -assert isinstance(_get_task_by_name(execution_tasks[2], execution_graph), - core.task.StartSubWorkflowTask) +assert expected_tasks_names == [t.api_id for t in execution_tasks] +assert all(isinstance(task, models.Task) for task in execution_tasks) +execution_tasks = iter(execution_tasks) -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[3], execution_graph), - inner_task) -assert isinstance(_get_task_by_name(execution_tasks[4], execution_graph), - core.task.EndSubWorkflowTask) +assert next(execution_tasks).stub_type == models.Task.START_WORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_before_task) +assert next(execution_tasks).stub_type == models.Task.START_SUBWROFKLOW +_assert_execution_is_api_task(next(execution_tasks), inner_task) +assert next(execution_tasks).stub_type == models.Task.END_SUBWORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_after_task) +assert next(execution_tasks).stub_type == models.Task.END_WORKFLOW -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[5], execution_graph), - simple_after_task) -assert
[1/2] incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-278-Remove-core-tasks 09c114bcc -> 25427ae59 (forced update) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/25427ae5/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py -- diff --git a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py index 5dd2855..de40fcf 100644 --- a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py +++ b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py @@ -13,12 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from networkx import topological_sort, DiGraph - -from aria.orchestrator import context -from aria.orchestrator.workflows import api, core +from networkx import topological_sort + +from aria.modeling import models +from aria.orchestrator import ( +context, +workflow_runner +) +from aria.orchestrator.workflows import api from aria.orchestrator.workflows.executor import base - from tests import mock from tests import storage @@ -26,8 +29,8 @@ from tests import storage def test_task_graph_into_execution_graph(tmpdir): interface_name = 'Standard' operation_name = 'create' -task_context = mock.context.simple(str(tmpdir)) -node = task_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) +workflow_context = mock.context.simple(str(tmpdir)) +node = workflow_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) interface = mock.models.create_interface( node.service, interface_name, @@ -35,12 +38,12 @@ def test_task_graph_into_execution_graph(tmpdir): operation_kwargs=dict(function='test') ) node.interfaces[interface.name] = interface -task_context.model.node.update(node) +workflow_context.model.node.update(node) def sub_workflow(name, **_): return api.task_graph.TaskGraph(name) -with context.workflow.current.push(task_context): +with context.workflow.current.push(workflow_context): test_task_graph = api.task.WorkflowTask(sub_workflow, name='test_task_graph') simple_before_task = api.task.OperationTask( node, @@ -65,11 +68,12 @@ def test_task_graph_into_execution_graph(tmpdir): test_task_graph.add_dependency(simple_after_task, inner_task_graph) # Direct check -execution_graph = DiGraph() -core.translation.build_execution_graph(task_graph=test_task_graph, - execution_graph=execution_graph, - default_executor=base.StubTaskExecutor()) -execution_tasks = topological_sort(execution_graph) +execution = workflow_context.model.execution.list()[0] + +workflow_runner.construct_execution_tasks(execution, test_task_graph, base.StubTaskExecutor) +workflow_context.execution = execution + +execution_tasks = topological_sort(workflow_context._graph) assert len(execution_tasks) == 7 @@ -83,30 +87,23 @@ def test_task_graph_into_execution_graph(tmpdir): '{0}-End'.format(test_task_graph.id) ] -assert expected_tasks_names == execution_tasks - -assert isinstance(_get_task_by_name(execution_tasks[0], execution_graph), - core.task.StartWorkflowTask) - -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[1], execution_graph), - simple_before_task) -assert isinstance(_get_task_by_name(execution_tasks[2], execution_graph), - core.task.StartSubWorkflowTask) +assert expected_tasks_names == [t.api_id for t in execution_tasks] +assert all(isinstance(task, models.Task) for task in execution_tasks) +execution_tasks = iter(execution_tasks) -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[3], execution_graph), - inner_task) -assert isinstance(_get_task_by_name(execution_tasks[4], execution_graph), - core.task.EndSubWorkflowTask) +assert next(execution_tasks).stub_type == models.Task.START_WORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_before_task) +assert next(execution_tasks).stub_type == models.Task.START_SUBWROFKLOW +_assert_execution_is_api_task(next(execution_tasks), inner_task) +assert next(execution_tasks).stub_type == models.Task.END_SUBWORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_after_task) +assert next(execution_tasks).stub_type == models.Task.END_WORKFLOW -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[5], execution_graph), - simple_after_task) -assert
[1/2] incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-278-Remove-core-tasks f29148af4 -> d517b820e (forced update) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d517b820/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py -- diff --git a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py index 5dd2855..de40fcf 100644 --- a/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py +++ b/tests/orchestrator/workflows/core/test_task_graph_into_execution_graph.py @@ -13,12 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from networkx import topological_sort, DiGraph - -from aria.orchestrator import context -from aria.orchestrator.workflows import api, core +from networkx import topological_sort + +from aria.modeling import models +from aria.orchestrator import ( +context, +workflow_runner +) +from aria.orchestrator.workflows import api from aria.orchestrator.workflows.executor import base - from tests import mock from tests import storage @@ -26,8 +29,8 @@ from tests import storage def test_task_graph_into_execution_graph(tmpdir): interface_name = 'Standard' operation_name = 'create' -task_context = mock.context.simple(str(tmpdir)) -node = task_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) +workflow_context = mock.context.simple(str(tmpdir)) +node = workflow_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) interface = mock.models.create_interface( node.service, interface_name, @@ -35,12 +38,12 @@ def test_task_graph_into_execution_graph(tmpdir): operation_kwargs=dict(function='test') ) node.interfaces[interface.name] = interface -task_context.model.node.update(node) +workflow_context.model.node.update(node) def sub_workflow(name, **_): return api.task_graph.TaskGraph(name) -with context.workflow.current.push(task_context): +with context.workflow.current.push(workflow_context): test_task_graph = api.task.WorkflowTask(sub_workflow, name='test_task_graph') simple_before_task = api.task.OperationTask( node, @@ -65,11 +68,12 @@ def test_task_graph_into_execution_graph(tmpdir): test_task_graph.add_dependency(simple_after_task, inner_task_graph) # Direct check -execution_graph = DiGraph() -core.translation.build_execution_graph(task_graph=test_task_graph, - execution_graph=execution_graph, - default_executor=base.StubTaskExecutor()) -execution_tasks = topological_sort(execution_graph) +execution = workflow_context.model.execution.list()[0] + +workflow_runner.construct_execution_tasks(execution, test_task_graph, base.StubTaskExecutor) +workflow_context.execution = execution + +execution_tasks = topological_sort(workflow_context._graph) assert len(execution_tasks) == 7 @@ -83,30 +87,23 @@ def test_task_graph_into_execution_graph(tmpdir): '{0}-End'.format(test_task_graph.id) ] -assert expected_tasks_names == execution_tasks - -assert isinstance(_get_task_by_name(execution_tasks[0], execution_graph), - core.task.StartWorkflowTask) - -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[1], execution_graph), - simple_before_task) -assert isinstance(_get_task_by_name(execution_tasks[2], execution_graph), - core.task.StartSubWorkflowTask) +assert expected_tasks_names == [t.api_id for t in execution_tasks] +assert all(isinstance(task, models.Task) for task in execution_tasks) +execution_tasks = iter(execution_tasks) -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[3], execution_graph), - inner_task) -assert isinstance(_get_task_by_name(execution_tasks[4], execution_graph), - core.task.EndSubWorkflowTask) +assert next(execution_tasks).stub_type == models.Task.START_WORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_before_task) +assert next(execution_tasks).stub_type == models.Task.START_SUBWROFKLOW +_assert_execution_is_api_task(next(execution_tasks), inner_task) +assert next(execution_tasks).stub_type == models.Task.END_SUBWORKFLOW +_assert_execution_is_api_task(next(execution_tasks), simple_after_task) +assert next(execution_tasks).stub_type == models.Task.END_WORKFLOW -_assert_execution_is_api_task(_get_task_by_name(execution_tasks[5], execution_graph), - simple_after_task) -assert
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-278-Remove-core-tasks 58e212c7d -> fc05b65d4 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/fc05b65d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/fc05b65d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/fc05b65d Branch: refs/heads/ARIA-278-Remove-core-tasks Commit: fc05b65d449bc67f817c48e7b0838a7c2705a7af Parents: 5afa2f7 Author: max-orlovAuthored: Sun Jun 11 19:05:35 2017 +0300 Committer: max-orlov Committed: Wed Jun 14 17:27:58 2017 +0300 -- aria/modeling/mixins.py | 4 +- aria/modeling/orchestration.py | 150 --- aria/orchestrator/context/operation.py | 3 + aria/orchestrator/workflow_runner.py| 118 +++- aria/orchestrator/workflows/core/__init__.py| 2 +- aria/orchestrator/workflows/core/_task.py | 265 ++ aria/orchestrator/workflows/core/engine.py | 67 +++-- .../workflows/core/events_handler.py| 77 +++--- aria/orchestrator/workflows/core/task.py| 269 --- aria/orchestrator/workflows/core/translation.py | 109 aria/orchestrator/workflows/events_logging.py | 25 +- aria/orchestrator/workflows/executor/base.py| 32 +-- aria/orchestrator/workflows/executor/process.py | 18 +- aria/orchestrator/workflows/executor/thread.py | 18 +- tests/orchestrator/context/__init__.py | 8 +- tests/orchestrator/context/test_operation.py| 26 +- tests/orchestrator/context/test_serialize.py| 11 +- .../orchestrator/execution_plugin/test_local.py | 11 +- .../orchestrator/workflows/core/test_engine.py | 14 +- .../orchestrator/workflows/core/test_events.py | 10 +- .../test_task_graph_into_execution_graph.py | 52 ++-- .../orchestrator/workflows/executor/__init__.py | 58 ++-- .../workflows/executor/test_executor.py | 95 +++ .../workflows/executor/test_process_executor.py | 1 - 24 files changed, 751 insertions(+), 692 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/fc05b65d/aria/modeling/mixins.py -- diff --git a/aria/modeling/mixins.py b/aria/modeling/mixins.py index c98a866..31675fe 100644 --- a/aria/modeling/mixins.py +++ b/aria/modeling/mixins.py @@ -18,14 +18,12 @@ classes: * ModelMixin - abstract model implementation. * ModelIDMixin - abstract model implementation with IDs. """ - from sqlalchemy.ext import associationproxy from sqlalchemy import ( Column, Integer, Text, -PickleType -) +PickleType) from ..parser.consumption import ConsumptionContext from ..utils import console, collections, caching, formatting http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/fc05b65d/aria/modeling/orchestration.py -- diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py index 995c8c2..c0b7f04 100644 --- a/aria/modeling/orchestration.py +++ b/aria/modeling/orchestration.py @@ -21,9 +21,10 @@ classes: """ # pylint: disable=no-self-argument, no-member, abstract-method - +from contextlib import contextmanager from datetime import datetime +from networkx import DiGraph from sqlalchemy import ( Column, Integer, @@ -34,19 +35,19 @@ from sqlalchemy import ( String, Float, orm, -) +PickleType) from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.ext.declarative import declared_attr from ..orchestrator.exceptions import (TaskAbortException, TaskRetryException) -from .mixins import ModelMixin, ParameterMixin +from . import mixins from . import ( relationship, types as modeling_types ) -class ExecutionBase(ModelMixin): +class ExecutionBase(mixins.ModelMixin): """ Execution model representation. """ @@ -152,7 +153,7 @@ class ExecutionBase(ModelMixin): ) -class PluginBase(ModelMixin): +class PluginBase(mixins.ModelMixin): """ An installed plugin. @@ -213,7 +214,7 @@ class PluginBase(ModelMixin): uploaded_at = Column(DateTime, nullable=False, index=True) -class TaskBase(ModelMixin): +class TaskBase(mixins.ModelMixin): """ Represents the smallest unit of stateful execution in ARIA. The task state includes inputs, outputs, as well as an atomic status, ensuring that the task can only be running once at any @@ -257,10 +258,25 @@ class TaskBase(ModelMixin): __tablename__ = 'task' -__private_fields__ = ['node_fk', -
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-213-Sporadic-tests-failures-over-locked-database-issue 6c055ce4e -> ceb1c0525 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/ceb1c052 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/ceb1c052 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/ceb1c052 Branch: refs/heads/ARIA-213-Sporadic-tests-failures-over-locked-database-issue Commit: ceb1c05256b0fba949956bf460cd2e1f6da6362b Parents: 180e0a1 Author: max-orlovAuthored: Tue Jun 6 17:05:21 2017 +0300 Committer: max-orlov Committed: Wed Jun 7 16:35:16 2017 +0300 -- aria/storage/sql_mapi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ceb1c052/aria/storage/sql_mapi.py -- diff --git a/aria/storage/sql_mapi.py b/aria/storage/sql_mapi.py index 4d7e233..bb6223a 100644 --- a/aria/storage/sql_mapi.py +++ b/aria/storage/sql_mapi.py @@ -405,7 +405,8 @@ def init_storage(base_dir, filename='db.sqlite'): path=os.path.join(base_dir, filename)) -engine = create_engine(uri) +engine = create_engine(uri, connect_args=dict(timeout=15)) + session_factory = orm.sessionmaker(bind=engine) session = orm.scoped_session(session_factory=session_factory)
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/database_locked_poc 7e70d719f -> fedfb0d40 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/fedfb0d4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/fedfb0d4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/fedfb0d4 Branch: refs/heads/database_locked_poc Commit: fedfb0d406937f93ac1376166162419719e09d09 Parents: 180e0a1 Author: max-orlovAuthored: Tue Jun 6 17:05:21 2017 +0300 Committer: max-orlov Committed: Wed Jun 7 11:05:05 2017 +0300 -- aria/storage/sql_mapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/fedfb0d4/aria/storage/sql_mapi.py -- diff --git a/aria/storage/sql_mapi.py b/aria/storage/sql_mapi.py index 4d7e233..68d0ff6 100644 --- a/aria/storage/sql_mapi.py +++ b/aria/storage/sql_mapi.py @@ -405,7 +405,7 @@ def init_storage(base_dir, filename='db.sqlite'): path=os.path.join(base_dir, filename)) -engine = create_engine(uri) +engine = create_engine(uri, connect_args=dict(timeout=15)) session_factory = orm.sessionmaker(bind=engine) session = orm.scoped_session(session_factory=session_factory)
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/database_locked_poc a34d7b954 -> 7e70d719f (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/7e70d719 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/7e70d719 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/7e70d719 Branch: refs/heads/database_locked_poc Commit: 7e70d719ffec65ad8e166b872e04023c2e6bb496 Parents: 180e0a1 Author: max-orlovAuthored: Tue Jun 6 17:05:21 2017 +0300 Committer: max-orlov Committed: Tue Jun 6 18:11:25 2017 +0300 -- aria/storage/sql_mapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7e70d719/aria/storage/sql_mapi.py -- diff --git a/aria/storage/sql_mapi.py b/aria/storage/sql_mapi.py index 4d7e233..68d0ff6 100644 --- a/aria/storage/sql_mapi.py +++ b/aria/storage/sql_mapi.py @@ -405,7 +405,7 @@ def init_storage(base_dir, filename='db.sqlite'): path=os.path.join(base_dir, filename)) -engine = create_engine(uri) +engine = create_engine(uri, connect_args=dict(timeout=15)) session_factory = orm.sessionmaker(bind=engine) session = orm.scoped_session(session_factory=session_factory)
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/database_locked_poc 872d2feec -> 9f9de45da (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9f9de45d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9f9de45d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9f9de45d Branch: refs/heads/database_locked_poc Commit: 9f9de45da38ec735e9d9603b49f4c875af830218 Parents: 180e0a1 Author: max-orlovAuthored: Tue Jun 6 17:05:21 2017 +0300 Committer: max-orlov Committed: Tue Jun 6 17:24:48 2017 +0300 -- aria/storage/sql_mapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9f9de45d/aria/storage/sql_mapi.py -- diff --git a/aria/storage/sql_mapi.py b/aria/storage/sql_mapi.py index 4d7e233..68d0ff6 100644 --- a/aria/storage/sql_mapi.py +++ b/aria/storage/sql_mapi.py @@ -405,7 +405,7 @@ def init_storage(base_dir, filename='db.sqlite'): path=os.path.join(base_dir, filename)) -engine = create_engine(uri) +engine = create_engine(uri, connect_args=dict(timeout=15)) session_factory = orm.sessionmaker(bind=engine) session = orm.scoped_session(session_factory=session_factory)
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-262-Inconsistent-node-attributes-behavior 700a3568c -> 512dddf14 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/512dddf1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/512dddf1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/512dddf1 Branch: refs/heads/ARIA-262-Inconsistent-node-attributes-behavior Commit: 512dddf147dfb6bd5c600ceb9390cc94ba8fcbbc Parents: adf7607 Author: max-orlovAuthored: Wed May 31 21:07:49 2017 +0300 Committer: max-orlov Committed: Wed May 31 21:09:25 2017 +0300 -- .../context/collection_instrumentation.py | 92 +--- aria/orchestrator/context/common.py | 5 ++ aria/orchestrator/context/operation.py | 22 ++--- 3 files changed, 74 insertions(+), 45 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/512dddf1/aria/orchestrator/context/collection_instrumentation.py -- diff --git a/aria/orchestrator/context/collection_instrumentation.py b/aria/orchestrator/context/collection_instrumentation.py index 91cfd35..00a9227 100644 --- a/aria/orchestrator/context/collection_instrumentation.py +++ b/aria/orchestrator/context/collection_instrumentation.py @@ -18,6 +18,30 @@ from functools import partial from aria.modeling import models +class _Wrapper(object): + +def __init__(self, instrumented_cls, instrumentation_cls, wrapped, **kwargs): +self._instrumented_cls = instrumented_cls +self._instrumentation_cls = instrumentation_cls +self._wrapped = wrapped +self._kwargs = kwargs + +def _wrap(self, value): +from aria.modeling.models import aria_declarative_base +if isinstance(value, self._instrumented_cls): +return Instrument(**self._kwargs) +elif isinstance(value, aria_declarative_base): +return _Wrapper( +self._instrumented_cls, self._instrumentation_cls, value, **self._kwargs) +return value + +def __getattr__(self, item): +return self._wrap(getattr(self._wrapped, item)) + +def __getitem__(self, item): +return self._wrap(self._wrapped[item]) + + class _InstrumentedCollection(object): def __init__(self, @@ -202,41 +226,47 @@ class _InstrumentedList(_InstrumentedCollection, list): return list(self) -class _InstrumentedModel(object): +class Instrument(object): -def __init__(self, field_name, original_model, model_storage): -super(_InstrumentedModel, self).__init__() -self._field_name = field_name +def __init__(self, original_model, model_storage, field_names): +super(Instrument, self).__init__() +self._field_names = field_names self._model_storage = model_storage self._original_model = original_model -self._apply_instrumentation() +self._instrumentation_cls = self._apply_instrumentation() def __getattr__(self, item): -return getattr(self._original_model, item) +return_value = getattr(self._original_model, item) +if isinstance(return_value, (list, dict)): +return _Wrapper(self._original_model.__class__, +self._instrumentation_cls, +return_value, +field_name=self._field_names, +original_model=self._original_model, +model_storage=self._model_storage, +) +return return_value def _apply_instrumentation(self): - -field = getattr(self._original_model, self._field_name) - -# Preserve the original value. e.g. original attributes would be located under -# _attributes -setattr(self, '_{0}'.format(self._field_name), field) - -# set instrumented value -setattr(self, self._field_name, _InstrumentedDict(self._model_storage, - self._original_model, - self._field_name, - field)) - - -def instrument_collection(field_name, func=None): -if func is None: -return partial(instrument_collection, field_name) - -def _wrapper(*args, **kwargs): -original_model = func(*args, **kwargs) -return type('Instrumented{0}'.format(original_model.__class__.__name__), -(_InstrumentedModel, ), -{})(field_name, original_model, args[0].model) -
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-213-Sporadic-tests-failures-over-locked-database-issue 0942b2e2e -> 5194ad2ac (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/5194ad2a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/5194ad2a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/5194ad2a Branch: refs/heads/ARIA-213-Sporadic-tests-failures-over-locked-database-issue Commit: 5194ad2acad91b719fbde2cff575a8704a844e05 Parents: 16fcca4 Author: max-orlovAuthored: Tue May 9 17:24:31 2017 +0300 Committer: max-orlov Committed: Tue May 9 17:25:55 2017 +0300 -- aria/logger.py | 22 ++ aria/orchestrator/context/common.py | 10 +++--- aria/storage/instrumentation.py | 21 ++--- tests/orchestrator/context/test_operation.py | 2 +- 4 files changed, 28 insertions(+), 27 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5194ad2a/aria/logger.py -- diff --git a/aria/logger.py b/aria/logger.py index 97d3878..9214bd9 100644 --- a/aria/logger.py +++ b/aria/logger.py @@ -114,14 +114,13 @@ def create_console_log_handler(level=logging.DEBUG, formatter=None): return console -def create_sqla_log_handler(session, engine, log_cls, execution_id, level=logging.DEBUG): +def create_sqla_log_handler(model, log_cls, execution_id, level=logging.DEBUG): # This is needed since the engine and session are entirely new we need to reflect the db # schema of the logging model into the engine and session. -log_cls.__table__.create(bind=engine, checkfirst=True) +log_cls.__table__.create(bind=model.log._engine, checkfirst=True) -return _SQLAlchemyHandler(session=session, - engine=engine, +return _SQLAlchemyHandler(model=model, log_cls=log_cls, execution_id=execution_id, level=level) @@ -168,10 +167,9 @@ def create_file_log_handler( class _SQLAlchemyHandler(logging.Handler): -def __init__(self, session, engine, log_cls, execution_id, **kwargs): +def __init__(self, model, log_cls, execution_id, **kwargs): logging.Handler.__init__(self, **kwargs) -self._session = session -self._engine = engine +self._model = model self._cls = log_cls self._execution_id = execution_id @@ -188,15 +186,7 @@ class _SQLAlchemyHandler(logging.Handler): # Not mandatory. traceback=getattr(record, 'traceback', None) ) -self._session.add(log) - -try: -self._session.commit() -except BaseException: -self._session.rollback() -raise -finally: -self._session.close() +self._model.log.put(log) _default_file_formatter = logging.Formatter( http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5194ad2a/aria/orchestrator/context/common.py -- diff --git a/aria/orchestrator/context/common.py b/aria/orchestrator/context/common.py index 64ef9a4..c0047e9 100644 --- a/aria/orchestrator/context/common.py +++ b/aria/orchestrator/context/common.py @@ -79,13 +79,9 @@ class BaseContext(object): self.logger.addHandler(self._get_sqla_handler()) def _get_sqla_handler(self): -api_kwargs = {} -if self._model._initiator: - api_kwargs.update(self._model._initiator(**self._model._initiator_kwargs)) -api_kwargs.update(**self._model._api_kwargs) -return aria_logger.create_sqla_log_handler(log_cls=modeling.models.Log, - execution_id=self._execution_id, - **api_kwargs) +return aria_logger.create_sqla_log_handler(model=self._model, + log_cls=modeling.models.Log, + execution_id=self._execution_id) def __repr__(self): return ( http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5194ad2a/aria/storage/instrumentation.py -- diff --git a/aria/storage/instrumentation.py b/aria/storage/instrumentation.py index cf2a365..14d4423 100644 --- a/aria/storage/instrumentation.py +++ b/aria/storage/instrumentation.py @@ -26,7 +26,15 @@ from ..storage.exceptions import
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-165-Make-node-name-suffix-UUIDs-become-more-readable a10e6dc68 -> 991fb6bd2 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/991fb6bd Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/991fb6bd Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/991fb6bd Branch: refs/heads/ARIA-165-Make-node-name-suffix-UUIDs-become-more-readable Commit: 991fb6bd210a916e214573796120aa782d3b81b0 Parents: 0ec2370 Author: max-orlovAuthored: Mon May 8 15:25:37 2017 +0300 Committer: max-orlov Committed: Mon May 8 17:21:07 2017 +0300 -- aria/modeling/service_template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/991fb6bd/aria/modeling/service_template.py -- diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py index 7fab4fc..5e4b661 100644 --- a/aria/modeling/service_template.py +++ b/aria/modeling/service_template.py @@ -549,9 +549,8 @@ class NodeTemplateBase(TemplateModelMixin): ('requirement_templates', formatting.as_raw_list(self.requirement_templates def instantiate(self, container): -context = ConsumptionContext.get_thread_local() from . import models -name = context.modeling.generate_node_id(self.name) +name = '{name}.{index}'.format(name=self.name, index=len(self.nodes)) node = models.Node(name=name, type=self.type, description=deepcopy_with_locators(self.description), @@ -562,6 +561,7 @@ class NodeTemplateBase(TemplateModelMixin): utils.instantiate_dict(node, node.interfaces, self.interface_templates) utils.instantiate_dict(node, node.artifacts, self.artifact_templates) utils.instantiate_dict(node, node.capabilities, self.capability_templates) +import pydevd; pydevd.settrace('localhost', suspend=False) return node def validate(self):
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-165-Make-node-name-suffix-UUIDs-become-more-readable aa57ad0b4 -> a10e6dc68 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/a10e6dc6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/a10e6dc6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/a10e6dc6 Branch: refs/heads/ARIA-165-Make-node-name-suffix-UUIDs-become-more-readable Commit: a10e6dc68bd13749abfb48b7dc032621a5181f5f Parents: 0ec2370 Author: max-orlovAuthored: Mon May 8 15:25:37 2017 +0300 Committer: max-orlov Committed: Mon May 8 17:09:02 2017 +0300 -- aria/modeling/service_template.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a10e6dc6/aria/modeling/service_template.py -- diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py index 7fab4fc..da83143 100644 --- a/aria/modeling/service_template.py +++ b/aria/modeling/service_template.py @@ -549,9 +549,8 @@ class NodeTemplateBase(TemplateModelMixin): ('requirement_templates', formatting.as_raw_list(self.requirement_templates def instantiate(self, container): -context = ConsumptionContext.get_thread_local() from . import models -name = context.modeling.generate_node_id(self.name) +name = '{name}.{index}'.format(self.name, len(self.nodes)) node = models.Node(name=name, type=self.type, description=deepcopy_with_locators(self.description),
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-165-Make-node-name-suffix-UUIDs-become-more-readable b9e5fb3c8 -> aa57ad0b4 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/aa57ad0b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/aa57ad0b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/aa57ad0b Branch: refs/heads/ARIA-165-Make-node-name-suffix-UUIDs-become-more-readable Commit: aa57ad0b4a2d1719956118a6774c43f69accdafb Parents: 0ec2370 Author: max-orlovAuthored: Mon May 8 15:25:37 2017 +0300 Committer: max-orlov Committed: Mon May 8 16:14:20 2017 +0300 -- aria/modeling/service_instance.py | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/aa57ad0b/aria/modeling/service_instance.py -- diff --git a/aria/modeling/service_instance.py b/aria/modeling/service_instance.py index ad8e7ed..18c920e 100644 --- a/aria/modeling/service_instance.py +++ b/aria/modeling/service_instance.py @@ -20,8 +20,8 @@ from sqlalchemy import ( Text, Integer, Enum, -Boolean -) +Boolean, +FetchedValue, event) from sqlalchemy import DateTime from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.ext.declarative import declared_attr @@ -688,6 +688,17 @@ class NodeBase(InstanceModelMixin): utils.dump_dict_values(self.capabilities, 'Capabilities') utils.dump_list_values(self.outbound_relationships, 'Relationships') +# @staticmethod +# def fill_name(mapper, connection, target): +# # Creating a trigger which updates the name right after the model is created on the +# # server-side +# import pydevd; +# pydevd.settrace('localhost', suspend=False) +# connection.execute(mapper.mapped_table.update().values(name=target.id)).where( +# NodeBase.c.id == target.id) + +# event.listen(NodeBase, 'after_insert', NodeBase.fill_name) + class GroupBase(InstanceModelMixin): """
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-160-Tests-fail-spordically-over-parameter-binding cadc9e552 -> fdcddc85c (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/fdcddc85 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/fdcddc85 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/fdcddc85 Branch: refs/heads/ARIA-160-Tests-fail-spordically-over-parameter-binding Commit: fdcddc85c9722fd22562018ca6c3cc3a5e1765d7 Parents: 0ec2370 Author: max-orlovAuthored: Mon May 8 14:46:58 2017 +0300 Committer: max-orlov Committed: Mon May 8 15:35:31 2017 +0300 -- aria/orchestrator/workflows/core/engine.py | 3 +- tests/helpers.py | 19 ++-- tests/orchestrator/context/test_operation.py | 107 -- tests/orchestrator/context/test_toolbelt.py | 38 4 files changed, 87 insertions(+), 80 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/fdcddc85/aria/orchestrator/workflows/core/engine.py -- diff --git a/aria/orchestrator/workflows/core/engine.py b/aria/orchestrator/workflows/core/engine.py index fd0dd6d..561265c 100644 --- a/aria/orchestrator/workflows/core/engine.py +++ b/aria/orchestrator/workflows/core/engine.py @@ -42,10 +42,9 @@ class Engine(logger.LoggerMixin): super(Engine, self).__init__(**kwargs) self._workflow_context = workflow_context self._execution_graph = networkx.DiGraph() -self._executor = executor translation.build_execution_graph(task_graph=tasks_graph, execution_graph=self._execution_graph, - default_executor=self._executor) + default_executor=executor) def execute(self): """ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/fdcddc85/tests/helpers.py -- diff --git a/tests/helpers.py b/tests/helpers.py index 423e63f..6dad4fa 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -14,7 +14,6 @@ # limitations under the License. import os -import tempfile import json from . import ROOT_DIR @@ -34,16 +33,17 @@ def get_service_template_uri(*args): class FilesystemDataHolder(object): -_tmpfile = tempfile.NamedTemporaryFile('w') def _load(self): -return json.load(open(self._tmpfile.name)) +return json.load(open(self._path)) def _dump(self, value): -return json.dump(value, open(self._tmpfile.name, 'w')) +return json.dump(value, open(self._path, 'w')) -def __init__(self): -self.clear() +def __init__(self, path, reset=False): +self._path = path +if reset or not os.path.exists(self._path) or open(self._path).read() == '': +self._dump({}) def __setitem__(self, key, value): dict_ = self._load() @@ -56,9 +56,6 @@ class FilesystemDataHolder(object): def __iter__(self): return iter(self._load()) -def clear(self): -self._dump({}) - def get(self, item, default=None): return self._load().get(item, default) @@ -67,3 +64,7 @@ class FilesystemDataHolder(object): return_value = dict_.setdefault(key, value) self._dump(dict_) return return_value + +@property +def path(self): +return self._path \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/fdcddc85/tests/orchestrator/context/test_operation.py -- diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py index 3180d89..9f70956 100644 --- a/tests/orchestrator/context/test_operation.py +++ b/tests/orchestrator/context/test_operation.py @@ -38,7 +38,6 @@ from . import ( execute, ) -global_test_holder = helpers.FilesystemDataHolder() @pytest.fixture def ctx(tmpdir): @@ -68,11 +67,18 @@ def thread_executor(): ex.close() -def test_node_operation_task_execution(ctx, thread_executor): +@pytest.fixture +def test_holder(tmpdir): +test_holder_path = str(tmpdir.join('test_holder')) +holder = helpers.FilesystemDataHolder(test_holder_path) +return holder + + +def test_node_operation_task_execution(ctx, thread_executor, test_holder): interface_name = 'Standard' operation_name = 'create' -inputs = {'putput': True} +inputs = {'putput': True, 'holder_path': test_holder.path} node
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-160-Tests-fail-spordically-over-parameter-binding bf7e64aa0 -> cadc9e552 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/cadc9e55 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/cadc9e55 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/cadc9e55 Branch: refs/heads/ARIA-160-Tests-fail-spordically-over-parameter-binding Commit: cadc9e5520809f1e698612bdd4ba97e926a9bccc Parents: b9e5fb3 Author: max-orlovAuthored: Mon May 8 14:46:58 2017 +0300 Committer: max-orlov Committed: Mon May 8 15:33:43 2017 +0300 -- aria/orchestrator/workflows/core/engine.py | 3 +- tests/helpers.py | 19 ++-- tests/orchestrator/context/test_operation.py | 107 -- tests/orchestrator/context/test_toolbelt.py | 38 4 files changed, 87 insertions(+), 80 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cadc9e55/aria/orchestrator/workflows/core/engine.py -- diff --git a/aria/orchestrator/workflows/core/engine.py b/aria/orchestrator/workflows/core/engine.py index fd0dd6d..561265c 100644 --- a/aria/orchestrator/workflows/core/engine.py +++ b/aria/orchestrator/workflows/core/engine.py @@ -42,10 +42,9 @@ class Engine(logger.LoggerMixin): super(Engine, self).__init__(**kwargs) self._workflow_context = workflow_context self._execution_graph = networkx.DiGraph() -self._executor = executor translation.build_execution_graph(task_graph=tasks_graph, execution_graph=self._execution_graph, - default_executor=self._executor) + default_executor=executor) def execute(self): """ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cadc9e55/tests/helpers.py -- diff --git a/tests/helpers.py b/tests/helpers.py index 423e63f..6dad4fa 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -14,7 +14,6 @@ # limitations under the License. import os -import tempfile import json from . import ROOT_DIR @@ -34,16 +33,17 @@ def get_service_template_uri(*args): class FilesystemDataHolder(object): -_tmpfile = tempfile.NamedTemporaryFile('w') def _load(self): -return json.load(open(self._tmpfile.name)) +return json.load(open(self._path)) def _dump(self, value): -return json.dump(value, open(self._tmpfile.name, 'w')) +return json.dump(value, open(self._path, 'w')) -def __init__(self): -self.clear() +def __init__(self, path, reset=False): +self._path = path +if reset or not os.path.exists(self._path) or open(self._path).read() == '': +self._dump({}) def __setitem__(self, key, value): dict_ = self._load() @@ -56,9 +56,6 @@ class FilesystemDataHolder(object): def __iter__(self): return iter(self._load()) -def clear(self): -self._dump({}) - def get(self, item, default=None): return self._load().get(item, default) @@ -67,3 +64,7 @@ class FilesystemDataHolder(object): return_value = dict_.setdefault(key, value) self._dump(dict_) return return_value + +@property +def path(self): +return self._path \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cadc9e55/tests/orchestrator/context/test_operation.py -- diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py index 3180d89..9f70956 100644 --- a/tests/orchestrator/context/test_operation.py +++ b/tests/orchestrator/context/test_operation.py @@ -38,7 +38,6 @@ from . import ( execute, ) -global_test_holder = helpers.FilesystemDataHolder() @pytest.fixture def ctx(tmpdir): @@ -68,11 +67,18 @@ def thread_executor(): ex.close() -def test_node_operation_task_execution(ctx, thread_executor): +@pytest.fixture +def test_holder(tmpdir): +test_holder_path = str(tmpdir.join('test_holder')) +holder = helpers.FilesystemDataHolder(test_holder_path) +return holder + + +def test_node_operation_task_execution(ctx, thread_executor, test_holder): interface_name = 'Standard' operation_name = 'create' -inputs = {'putput': True} +inputs = {'putput': True, 'holder_path': test_holder.path} node
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/parameter_issue aa5fbb977 -> bf7e64aa0 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/bf7e64aa Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/bf7e64aa Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/bf7e64aa Branch: refs/heads/parameter_issue Commit: bf7e64aa0bf27b8b8f10af7e15729b1449bf45e8 Parents: b9e5fb3 Author: max-orlovAuthored: Mon May 8 14:46:58 2017 +0300 Committer: max-orlov Committed: Mon May 8 15:25:45 2017 +0300 -- aria/orchestrator/workflows/core/engine.py | 3 +- tests/helpers.py | 19 ++-- tests/orchestrator/context/test_operation.py | 107 -- tests/orchestrator/context/test_toolbelt.py | 38 4 files changed, 87 insertions(+), 80 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/bf7e64aa/aria/orchestrator/workflows/core/engine.py -- diff --git a/aria/orchestrator/workflows/core/engine.py b/aria/orchestrator/workflows/core/engine.py index fd0dd6d..561265c 100644 --- a/aria/orchestrator/workflows/core/engine.py +++ b/aria/orchestrator/workflows/core/engine.py @@ -42,10 +42,9 @@ class Engine(logger.LoggerMixin): super(Engine, self).__init__(**kwargs) self._workflow_context = workflow_context self._execution_graph = networkx.DiGraph() -self._executor = executor translation.build_execution_graph(task_graph=tasks_graph, execution_graph=self._execution_graph, - default_executor=self._executor) + default_executor=executor) def execute(self): """ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/bf7e64aa/tests/helpers.py -- diff --git a/tests/helpers.py b/tests/helpers.py index 423e63f..6dad4fa 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -14,7 +14,6 @@ # limitations under the License. import os -import tempfile import json from . import ROOT_DIR @@ -34,16 +33,17 @@ def get_service_template_uri(*args): class FilesystemDataHolder(object): -_tmpfile = tempfile.NamedTemporaryFile('w') def _load(self): -return json.load(open(self._tmpfile.name)) +return json.load(open(self._path)) def _dump(self, value): -return json.dump(value, open(self._tmpfile.name, 'w')) +return json.dump(value, open(self._path, 'w')) -def __init__(self): -self.clear() +def __init__(self, path, reset=False): +self._path = path +if reset or not os.path.exists(self._path) or open(self._path).read() == '': +self._dump({}) def __setitem__(self, key, value): dict_ = self._load() @@ -56,9 +56,6 @@ class FilesystemDataHolder(object): def __iter__(self): return iter(self._load()) -def clear(self): -self._dump({}) - def get(self, item, default=None): return self._load().get(item, default) @@ -67,3 +64,7 @@ class FilesystemDataHolder(object): return_value = dict_.setdefault(key, value) self._dump(dict_) return return_value + +@property +def path(self): +return self._path \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/bf7e64aa/tests/orchestrator/context/test_operation.py -- diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py index 3180d89..9f70956 100644 --- a/tests/orchestrator/context/test_operation.py +++ b/tests/orchestrator/context/test_operation.py @@ -38,7 +38,6 @@ from . import ( execute, ) -global_test_holder = helpers.FilesystemDataHolder() @pytest.fixture def ctx(tmpdir): @@ -68,11 +67,18 @@ def thread_executor(): ex.close() -def test_node_operation_task_execution(ctx, thread_executor): +@pytest.fixture +def test_holder(tmpdir): +test_holder_path = str(tmpdir.join('test_holder')) +holder = helpers.FilesystemDataHolder(test_holder_path) +return holder + + +def test_node_operation_task_execution(ctx, thread_executor, test_holder): interface_name = 'Standard' operation_name = 'create' -inputs = {'putput': True} +inputs = {'putput': True, 'holder_path': test_holder.path} node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) interface =
incubator-ariatosca git commit: wip...! [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-214-Dry-execution-changes-the-state-of-non-implemented-operations 3d36ebf12 -> eaa84b0ca (forced update) wip...! Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/eaa84b0c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/eaa84b0c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/eaa84b0c Branch: refs/heads/ARIA-214-Dry-execution-changes-the-state-of-non-implemented-operations Commit: eaa84b0cacfe5e18b6841c33b6127626e2ebcfad Parents: bfbd86f Author: max-orlovAuthored: Sun May 7 19:04:29 2017 +0300 Committer: max-orlov Committed: Sun May 7 19:24:59 2017 +0300 -- aria/orchestrator/workflows/executor/base.py | 8 aria/orchestrator/workflows/executor/dry.py | 2 +- .../orchestrator/workflows/executor/test_process_executor.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eaa84b0c/aria/orchestrator/workflows/executor/base.py -- diff --git a/aria/orchestrator/workflows/executor/base.py b/aria/orchestrator/workflows/executor/base.py index e55c736..8682e09 100644 --- a/aria/orchestrator/workflows/executor/base.py +++ b/aria/orchestrator/workflows/executor/base.py @@ -33,11 +33,11 @@ class BaseExecutor(logger.LoggerMixin): Execute a task :param task: task to execute """ -if getattr(task, 'model_task') and task.model_task.implementation: +if task.implementation: +self._execute(task) +else: self._task_started(task) self._task_succeeded(task) -else: -self._execute(task) def close(self): """ @@ -58,6 +58,6 @@ class BaseExecutor(logger.LoggerMixin): events.on_success_task_signal.send(task) -class StubTaskExecutor(BaseExecutor): +class StubTaskExecutor(BaseExecutor): # pylint: disable=abstract-method def execute(self, task): task.status = task.SUCCESS http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eaa84b0c/aria/orchestrator/workflows/executor/dry.py -- diff --git a/aria/orchestrator/workflows/executor/dry.py b/aria/orchestrator/workflows/executor/dry.py index 5a4ca73..f6fb7a6 100644 --- a/aria/orchestrator/workflows/executor/dry.py +++ b/aria/orchestrator/workflows/executor/dry.py @@ -21,7 +21,7 @@ from datetime import datetime from .base import BaseExecutor -class DryExecutor(BaseExecutor): +class DryExecutor(BaseExecutor): # pylint: disable=abstract-method """ Executor which dry runs tasks - prints task information without causing any side effects """ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eaa84b0c/tests/orchestrator/workflows/executor/test_process_executor.py -- diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py index 81dd691..5f240b2 100644 --- a/tests/orchestrator/workflows/executor/test_process_executor.py +++ b/tests/orchestrator/workflows/executor/test_process_executor.py @@ -65,7 +65,7 @@ class TestProcessExecutor(object): def test_closed(self, executor): executor.close() with pytest.raises(RuntimeError) as exc_info: -executor.execute(task=MockTask(implementation=None)) + executor.execute(task=MockTask(implementation='some.implementation')) assert 'closed' in exc_info.value.message
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-146-Support-colorful-execution-logging c5e1b1153 -> 18046aac3 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/18046aac Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/18046aac Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/18046aac Branch: refs/heads/ARIA-146-Support-colorful-execution-logging Commit: 18046aac31291b623cc917d32f7c10e2f3b962e7 Parents: b69a459 Author: max-orlovAuthored: Tue Apr 25 11:02:30 2017 +0300 Committer: max-orlov Committed: Tue Apr 25 11:33:47 2017 +0300 -- aria/cli/color.py | 73 aria/cli/config/config_template.yaml| 1 - aria/cli/execution_logging.py | 110 ++- aria/cli/logger.py | 17 --- .../execution_plugin/ssh/operations.py | 5 - 5 files changed, 131 insertions(+), 75 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/18046aac/aria/cli/color.py -- diff --git a/aria/cli/color.py b/aria/cli/color.py new file mode 100644 index 000..77bfe77 --- /dev/null +++ b/aria/cli/color.py @@ -0,0 +1,73 @@ +# 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. +from StringIO import StringIO + +import colorama + +colorama.init() + + +def _get_colors(color_type): +for name in dir(color_type): +if not name.startswith('_'): +yield (name.lower(), getattr(color_type, name)) + + +class Color(object): +Fore = colorama.Fore +Back = colorama.Back +Style = colorama.Style + +_colors = { +'fore': dict(_get_colors(Fore)), +'back': dict(_get_colors(Back)), +'style': dict(_get_colors(Style)) +} + +class Schema(object): +def __init__(self, **kwargs): +""" +It is possible to provide fore, back and style arguments. each could be either +the color is lower case letter, or the actual color from colorama. + +""" +assert all(arg in Color._colors for arg in kwargs) +self._kwargs = kwargs +self._str = StringIO() +for type_, colors in Color._colors.items(): +value = kwargs.pop(type_, None) +# the former case is if the value is a string, the latter is in case of an object. +self._str.write(colors.get(value) or value) + +def __str__(self): +return self._str.getvalue() + +def __add__(self, other): +return str(self) + str(other) + +def __radd__(self, other): +return str(other) + str(self) + +@classmethod +def stylize(cls, str_to_stylize, schema): +return schema + str(str_to_stylize) + cls.Style.RESET_ALL + +@classmethod +def markup(cls, str_to_stylize, matches, schema): +modified_str = str_to_stylize +for group_index in xrange(len(matches.regs)): +match = matches.group(group_index) +modified_str = modified_str.replace(match, schema + match + cls.Back.RESET) +return modified_str http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/18046aac/aria/cli/config/config_template.yaml -- diff --git a/aria/cli/config/config_template.yaml b/aria/cli/config/config_template.yaml index 13f2cf9..66c606e 100644 --- a/aria/cli/config/config_template.yaml +++ b/aria/cli/config/config_template.yaml @@ -1,4 +1,3 @@ -colors: {{ enable_colors }} logging: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/18046aac/aria/cli/execution_logging.py -- diff --git a/aria/cli/execution_logging.py b/aria/cli/execution_logging.py index 9631d30..c6d7266 100644 ---
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-146-Support-colorful-execution-logging db0be8784 -> c5e1b1153 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/c5e1b115 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c5e1b115 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c5e1b115 Branch: refs/heads/ARIA-146-Support-colorful-execution-logging Commit: c5e1b11539a2c2667b52b24fbf2404d6cbc61bb3 Parents: b69a459 Author: max-orlovAuthored: Tue Apr 25 11:02:30 2017 +0300 Committer: max-orlov Committed: Tue Apr 25 11:10:32 2017 +0300 -- aria/cli/color.py| 73 aria/cli/config/config_template.yaml | 1 - aria/cli/execution_logging.py| 110 -- aria/cli/logger.py | 17 - 4 files changed, 131 insertions(+), 70 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c5e1b115/aria/cli/color.py -- diff --git a/aria/cli/color.py b/aria/cli/color.py new file mode 100644 index 000..77bfe77 --- /dev/null +++ b/aria/cli/color.py @@ -0,0 +1,73 @@ +# 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. +from StringIO import StringIO + +import colorama + +colorama.init() + + +def _get_colors(color_type): +for name in dir(color_type): +if not name.startswith('_'): +yield (name.lower(), getattr(color_type, name)) + + +class Color(object): +Fore = colorama.Fore +Back = colorama.Back +Style = colorama.Style + +_colors = { +'fore': dict(_get_colors(Fore)), +'back': dict(_get_colors(Back)), +'style': dict(_get_colors(Style)) +} + +class Schema(object): +def __init__(self, **kwargs): +""" +It is possible to provide fore, back and style arguments. each could be either +the color is lower case letter, or the actual color from colorama. + +""" +assert all(arg in Color._colors for arg in kwargs) +self._kwargs = kwargs +self._str = StringIO() +for type_, colors in Color._colors.items(): +value = kwargs.pop(type_, None) +# the former case is if the value is a string, the latter is in case of an object. +self._str.write(colors.get(value) or value) + +def __str__(self): +return self._str.getvalue() + +def __add__(self, other): +return str(self) + str(other) + +def __radd__(self, other): +return str(other) + str(self) + +@classmethod +def stylize(cls, str_to_stylize, schema): +return schema + str(str_to_stylize) + cls.Style.RESET_ALL + +@classmethod +def markup(cls, str_to_stylize, matches, schema): +modified_str = str_to_stylize +for group_index in xrange(len(matches.regs)): +match = matches.group(group_index) +modified_str = modified_str.replace(match, schema + match + cls.Back.RESET) +return modified_str http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c5e1b115/aria/cli/config/config_template.yaml -- diff --git a/aria/cli/config/config_template.yaml b/aria/cli/config/config_template.yaml index 13f2cf9..66c606e 100644 --- a/aria/cli/config/config_template.yaml +++ b/aria/cli/config/config_template.yaml @@ -1,4 +1,3 @@ -colors: {{ enable_colors }} logging: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c5e1b115/aria/cli/execution_logging.py -- diff --git a/aria/cli/execution_logging.py b/aria/cli/execution_logging.py index 9631d30..c6d7266 100644 --- a/aria/cli/execution_logging.py +++ b/aria/cli/execution_logging.py @@ -16,9
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-138-Make-logging-more-informative e2655e48b -> 38dfa1b72 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/38dfa1b7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/38dfa1b7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/38dfa1b7 Branch: refs/heads/ARIA-138-Make-logging-more-informative Commit: 38dfa1b722b21e275ea97faf8bb5353a840d4a6e Parents: d90194d Author: max-orlovAuthored: Wed Apr 19 20:06:48 2017 +0300 Committer: max-orlov Committed: Wed Apr 19 21:34:41 2017 +0300 -- aria/orchestrator/execution_plugin/instantiation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/38dfa1b7/aria/orchestrator/execution_plugin/instantiation.py -- diff --git a/aria/orchestrator/execution_plugin/instantiation.py b/aria/orchestrator/execution_plugin/instantiation.py index 7627a38..db33cf3 100644 --- a/aria/orchestrator/execution_plugin/instantiation.py +++ b/aria/orchestrator/execution_plugin/instantiation.py @@ -73,8 +73,8 @@ def _configure_remote(operation, configuration, arguments): if ('password' not in ssh) and ('key' not in ssh) and ('key_filename' not in ssh): ssh['password'] = default_password -arguments['use_sudo'] = ssh.get('use_sudo') -arguments['hide_output'] = ssh.get('hide_output') +arguments['use_sudo'] = ssh.get('use_sudo', False) +arguments['hide_output'] = ssh.get('hide_output', dict(everything=False)) arguments['fabric_env'] = {} if 'warn_only' in ssh: arguments['fabric_env']['warn_only'] = ssh['warn_only']
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-106-Create-sqla-logging-handler 5788f652f -> d483195bd (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d483195b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d483195b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d483195b Branch: refs/heads/ARIA-106-Create-sqla-logging-handler Commit: d483195bd7467abbb7bdafb5a9e2f263b6d5dffe Parents: b619335 Author: mxmrlvAuthored: Mon Feb 13 12:28:27 2017 +0200 Committer: mxmrlv Committed: Mon Feb 13 20:29:48 2017 +0200 -- aria/__init__.py| 3 +- aria/logger.py | 43 +++- aria/orchestrator/context/common.py | 22 +- aria/orchestrator/workflows/core/engine.py | 5 ++ aria/orchestrator/workflows/executor/process.py | 1 - aria/storage/__init__.py| 6 -- aria/storage/core.py| 16 +++-- aria/storage/modeling/model.py | 4 ++ aria/storage/modeling/orchestrator_elements.py | 12 tests/mock/topology.py | 2 +- tests/orchestrator/context/test_operation.py| 74 ++-- .../execution_plugin/test_common.py | 2 +- tests/orchestrator/execution_plugin/test_ssh.py | 2 +- .../workflows/executor/test_process_executor.py | 6 +- tests/storage/__init__.py | 23 +++--- tests/storage/test_instrumentation.py | 6 +- tests/storage/test_structures.py| 2 +- 17 files changed, 182 insertions(+), 47 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d483195b/aria/__init__.py -- diff --git a/aria/__init__.py b/aria/__init__.py index 18eaa56..43529f0 100644 --- a/aria/__init__.py +++ b/aria/__init__.py @@ -97,7 +97,8 @@ def application_model_storage(api, api_kwargs=None, initiator=None, initiator_kw storage.modeling.model.ServiceInstanceUpdateStep, storage.modeling.model.ServiceInstanceModification, storage.modeling.model.Plugin, -storage.modeling.model.Task +storage.modeling.model.Task, +storage.modeling.model.Log ] return storage.ModelStorage(api_cls=api, api_kwargs=api_kwargs, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d483195b/aria/logger.py -- diff --git a/aria/logger.py b/aria/logger.py index 0002cb5..ebe01ba 100644 --- a/aria/logger.py +++ b/aria/logger.py @@ -17,8 +17,10 @@ Logging related mixins and functions """ + import logging -from logging.handlers import RotatingFileHandler +from logging import handlers as logging_handlers +from datetime import datetime _base_logger = logging.getLogger('aria') @@ -124,7 +126,7 @@ def create_file_log_handler( """ Create a logging.handlers.RotatingFileHandler """ -rotating_file = RotatingFileHandler( +rotating_file = logging_handlers.RotatingFileHandler( filename=file_path, maxBytes=max_bytes, backupCount=backup_count, @@ -135,5 +137,42 @@ def create_file_log_handler( return rotating_file +class SQLAlchemyHandler(logging.Handler): +def __init__(self, session, engine, log_cls, **kwargs): +self._session = session +self._engine = engine +self._cls = log_cls +super(SQLAlchemyHandler, self).__init__(**kwargs) + +def emit(self, record): +log = self._cls( +logger=record.name, +level=record.levelname, +msg=record.msg, +created_at=datetime.utcnow() +) +self._session.add(log) +self._session.commit() + + +class _SQLAlchemyHandlerFactory(object): +# prevents circular imports +from aria.storage.modeling.model import Log + +def __init__(self): +self._handler = None + +def __call__(self, session, engine, model_cls=Log, level=logging.DEBUG): +if self._handler is None or not self._is_eq(session, engine, model_cls): +self._handler = SQLAlchemyHandler(session, engine, model_cls, level=level) +return self._handler + +def _is_eq(self, session, engine, model_cls): +return all([self._handler._session == session, +self._handler._engine == engine, +self._handler._cls == model_cls]) + +create_sqla_log_handler = _SQLAlchemyHandlerFactory() + _default_file_formatter = logging.Formatter( '%(asctime)s
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-106-Create-sqla-logging-handler 67b754254 -> 5788f652f (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/5788f652 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/5788f652 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/5788f652 Branch: refs/heads/ARIA-106-Create-sqla-logging-handler Commit: 5788f652f8a985f9038f0c68915b7ab875093f6b Parents: b619335 Author: mxmrlvAuthored: Mon Feb 13 12:28:27 2017 +0200 Committer: mxmrlv Committed: Mon Feb 13 20:24:36 2017 +0200 -- aria/__init__.py| 3 +- aria/logger.py | 43 +++- aria/orchestrator/context/common.py | 22 +- aria/orchestrator/workflows/core/engine.py | 5 ++ aria/orchestrator/workflows/executor/process.py | 1 - aria/storage/__init__.py| 6 -- aria/storage/core.py| 16 +++-- aria/storage/modeling/model.py | 4 ++ aria/storage/modeling/orchestrator_elements.py | 12 tests/mock/topology.py | 2 +- tests/orchestrator/context/test_operation.py| 74 ++-- tests/storage/__init__.py | 23 +++--- tests/storage/test_instrumentation.py | 6 +- 13 files changed, 177 insertions(+), 40 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5788f652/aria/__init__.py -- diff --git a/aria/__init__.py b/aria/__init__.py index 18eaa56..43529f0 100644 --- a/aria/__init__.py +++ b/aria/__init__.py @@ -97,7 +97,8 @@ def application_model_storage(api, api_kwargs=None, initiator=None, initiator_kw storage.modeling.model.ServiceInstanceUpdateStep, storage.modeling.model.ServiceInstanceModification, storage.modeling.model.Plugin, -storage.modeling.model.Task +storage.modeling.model.Task, +storage.modeling.model.Log ] return storage.ModelStorage(api_cls=api, api_kwargs=api_kwargs, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5788f652/aria/logger.py -- diff --git a/aria/logger.py b/aria/logger.py index 0002cb5..ebe01ba 100644 --- a/aria/logger.py +++ b/aria/logger.py @@ -17,8 +17,10 @@ Logging related mixins and functions """ + import logging -from logging.handlers import RotatingFileHandler +from logging import handlers as logging_handlers +from datetime import datetime _base_logger = logging.getLogger('aria') @@ -124,7 +126,7 @@ def create_file_log_handler( """ Create a logging.handlers.RotatingFileHandler """ -rotating_file = RotatingFileHandler( +rotating_file = logging_handlers.RotatingFileHandler( filename=file_path, maxBytes=max_bytes, backupCount=backup_count, @@ -135,5 +137,42 @@ def create_file_log_handler( return rotating_file +class SQLAlchemyHandler(logging.Handler): +def __init__(self, session, engine, log_cls, **kwargs): +self._session = session +self._engine = engine +self._cls = log_cls +super(SQLAlchemyHandler, self).__init__(**kwargs) + +def emit(self, record): +log = self._cls( +logger=record.name, +level=record.levelname, +msg=record.msg, +created_at=datetime.utcnow() +) +self._session.add(log) +self._session.commit() + + +class _SQLAlchemyHandlerFactory(object): +# prevents circular imports +from aria.storage.modeling.model import Log + +def __init__(self): +self._handler = None + +def __call__(self, session, engine, model_cls=Log, level=logging.DEBUG): +if self._handler is None or not self._is_eq(session, engine, model_cls): +self._handler = SQLAlchemyHandler(session, engine, model_cls, level=level) +return self._handler + +def _is_eq(self, session, engine, model_cls): +return all([self._handler._session == session, +self._handler._engine == engine, +self._handler._cls == model_cls]) + +create_sqla_log_handler = _SQLAlchemyHandlerFactory() + _default_file_formatter = logging.Formatter( '%(asctime)s [%(name)s:%(levelname)s] %(message)s <%(pathname)s:%(lineno)d>') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5788f652/aria/orchestrator/context/common.py --
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-106-Create-sqla-logging-handler 51b17799f -> 6bff90672 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/6bff9067 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/6bff9067 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/6bff9067 Branch: refs/heads/ARIA-106-Create-sqla-logging-handler Commit: 6bff90672b0781fb425beffcbda950dfbecc37a7 Parents: 2286b0d Author: mxmrlvAuthored: Mon Feb 13 13:50:05 2017 +0200 Committer: mxmrlv Committed: Mon Feb 13 19:09:29 2017 +0200 -- aria/__init__.py| 1 - aria/logger.py | 37 +--- aria/orchestrator/context/common.py | 23 ++-- aria/orchestrator/workflows/core/engine.py | 5 +++ aria/orchestrator/workflows/core/task.py| 2 -- aria/orchestrator/workflows/executor/process.py | 1 - aria/storage/model.py | 2 +- tests/orchestrator/context/test_operation.py| 6 ++-- tests/storage/__init__.py | 13 +++ 9 files changed, 50 insertions(+), 40 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6bff9067/aria/__init__.py -- diff --git a/aria/__init__.py b/aria/__init__.py index 4e2982f..2302b06 100644 --- a/aria/__init__.py +++ b/aria/__init__.py @@ -77,7 +77,6 @@ def application_model_storage(api, api_kwargs=None, initiator=None, initiator_kw storage.model.Execution, storage.model.Task, - storage.model.Log ] return storage.ModelStorage(api_cls=api, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6bff9067/aria/logger.py -- diff --git a/aria/logger.py b/aria/logger.py index 5840cff..f19d286 100644 --- a/aria/logger.py +++ b/aria/logger.py @@ -17,10 +17,10 @@ Logging related mixins and functions """ -import logging +import logging +from logging import handlers as logging_handlers from datetime import datetime -from logging.handlers import RotatingFileHandler _base_logger = logging.getLogger('aria') @@ -126,7 +126,7 @@ def create_file_log_handler( """ Create a logging.handlers.RotatingFileHandler """ -rotating_file = RotatingFileHandler( +rotating_file = logging_handlers.RotatingFileHandler( filename=file_path, maxBytes=max_bytes, backupCount=backup_count, @@ -137,15 +137,6 @@ def create_file_log_handler( return rotating_file -def create_sqla_log_handler(session, engine, model_cls=None, level=logging.DEBUG): -from aria.storage.model import Log -return SQLAlchemyHandler(session, engine, model_cls or Log, level=level) - - -_default_file_formatter = logging.Formatter( -'%(asctime)s [%(name)s:%(levelname)s] %(message)s <%(pathname)s:%(lineno)d>') - - class SQLAlchemyHandler(logging.Handler): def __init__(self, session, engine, log_cls, **kwargs): self._session = session @@ -162,3 +153,25 @@ class SQLAlchemyHandler(logging.Handler): ) self._session.add(log) self._session.commit() + + +class _SQLAlchemyHandlerFactory(object): +from aria.storage.model import Log + +def __init__(self): +self._handler = None + +def __call__(self, session, engine, model_cls=Log, level=logging.DEBUG): +if self._handler is None or not self._is_eq(session, engine, model_cls): +self._handler = SQLAlchemyHandler(session, engine, model_cls, level=level) +return self._handler + +def _is_eq(self, session, engine, model_cls): +return all([self._handler._session == session, +self._handler._engine == engine, +self._handler._cls == model_cls]) + +create_sqla_log_handler = _SQLAlchemyHandlerFactory() + +_default_file_formatter = logging.Formatter( +'%(asctime)s [%(name)s:%(levelname)s] %(message)s <%(pathname)s:%(lineno)d>') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6bff9067/aria/orchestrator/context/common.py -- diff --git a/aria/orchestrator/context/common.py b/aria/orchestrator/context/common.py index 87f88b1..3f29ac0 100644 --- a/aria/orchestrator/context/common.py +++ b/aria/orchestrator/context/common.py @@ -17,9 +17,10 @@ A common context for both workflow and operation """ from uuid import uuid4 -import jinja2 import logging +import jinja2 + from aria import logger from aria.storage import
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-106-Create-sqla-logging-handler 51c70c86a -> d868713c4 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d868713c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d868713c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d868713c Branch: refs/heads/ARIA-106-Create-sqla-logging-handler Commit: d868713c4636bcc7e811564f2bcad7b321824fca Parents: 1498ad3 Author: mxmrlvAuthored: Mon Feb 13 12:28:27 2017 +0200 Committer: mxmrlv Committed: Mon Feb 13 12:28:27 2017 +0200 -- aria/__init__.py | 2 ++ aria/logger.py | 25 + aria/storage/base_model.py | 12 aria/storage/model.py | 4 tests/storage/__init__.py | 3 +-- 5 files changed, 44 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d868713c/aria/__init__.py -- diff --git a/aria/__init__.py b/aria/__init__.py index 8b87473..4e2982f 100644 --- a/aria/__init__.py +++ b/aria/__init__.py @@ -77,6 +77,8 @@ def application_model_storage(api, api_kwargs=None, initiator=None, initiator_kw storage.model.Execution, storage.model.Task, + +storage.model.Log ] return storage.ModelStorage(api_cls=api, api_kwargs=api_kwargs, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d868713c/aria/logger.py -- diff --git a/aria/logger.py b/aria/logger.py index 0002cb5..5840cff 100644 --- a/aria/logger.py +++ b/aria/logger.py @@ -18,6 +18,8 @@ Logging related mixins and functions """ import logging + +from datetime import datetime from logging.handlers import RotatingFileHandler _base_logger = logging.getLogger('aria') @@ -135,5 +137,28 @@ def create_file_log_handler( return rotating_file +def create_sqla_log_handler(session, engine, model_cls=None, level=logging.DEBUG): +from aria.storage.model import Log +return SQLAlchemyHandler(session, engine, model_cls or Log, level=level) + + _default_file_formatter = logging.Formatter( '%(asctime)s [%(name)s:%(levelname)s] %(message)s <%(pathname)s:%(lineno)d>') + + +class SQLAlchemyHandler(logging.Handler): +def __init__(self, session, engine, log_cls, **kwargs): +self._session = session +self._engine = engine +self._cls = log_cls +super(SQLAlchemyHandler, self).__init__(**kwargs) + +def emit(self, record): +log = self._cls( +logger=record.name, +level=record.levelname, +msg=record.msg, +created_at=datetime.utcnow() +) +self._session.add(log) +self._session.commit() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d868713c/aria/storage/base_model.py -- diff --git a/aria/storage/base_model.py b/aria/storage/base_model.py index f7d0e5b..a24b1f9 100644 --- a/aria/storage/base_model.py +++ b/aria/storage/base_model.py @@ -755,3 +755,15 @@ class TaskBase(ModelMixin): @staticmethod def retry(message=None, retry_interval=None): raise TaskRetryException(message, retry_interval=retry_interval) + + +class LogBase(ModelMixin): +__tablename__ = 'log' + +logger = Column(String) +level = Column(String) +msg = Column(String) +created_at = Column(DateTime, index=True) + +def __repr__(self): +return "".format(self.created_at, self.msg[:50]) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d868713c/aria/storage/model.py -- diff --git a/aria/storage/model.py b/aria/storage/model.py index afca3e4..23fbb88 100644 --- a/aria/storage/model.py +++ b/aria/storage/model.py @@ -108,3 +108,7 @@ class Plugin(DeclarativeBase, base.PluginBase): class Task(DeclarativeBase, base.TaskBase): pass + + +class Log(DeclarativeBase, base.LogBase): +pass \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d868713c/tests/storage/__init__.py -- diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py index b798e01..2ba6da9 100644 --- a/tests/storage/__init__.py +++ b/tests/storage/__init__.py @@ -12,8 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-66-Convert-custom-parser-fields-into-sqla-based-fields d05373b0e -> 49f21eaf8 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/49f21eaf Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/49f21eaf Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/49f21eaf Branch: refs/heads/ARIA-66-Convert-custom-parser-fields-into-sqla-based-fields Commit: 49f21eaf8e273de847c920eae4400b301d4390c5 Parents: 64a393e Author: mxmrlvAuthored: Mon Jan 30 17:05:14 2017 +0200 Committer: mxmrlv Committed: Mon Jan 30 17:49:47 2017 +0200 -- aria/storage/type.py | 126 +- tests/storage/__init__.py| 19 ++--- tests/storage/test_structures.py | 26 +++ 3 files changed, 85 insertions(+), 86 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/49f21eaf/aria/storage/type.py -- diff --git a/aria/storage/type.py b/aria/storage/type.py index 1b28f33..8fb02c6 100644 --- a/aria/storage/type.py +++ b/aria/storage/type.py @@ -12,19 +12,18 @@ # 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. + import json from collections import namedtuple -from types import NoneType from sqlalchemy import ( TypeDecorator, VARCHAR, event ) - from sqlalchemy.ext import mutable -from . import exceptions +from aria.storage import exceptions class _MutableType(TypeDecorator): @@ -64,10 +63,6 @@ class List(_MutableType): class _StrictDictMixin(object): -ANY_TYPE = 'any_type' - -_key_cls = ANY_TYPE -_value_cls = ANY_TYPE @classmethod def coerce(cls, key, value): @@ -95,26 +90,22 @@ class _StrictDictMixin(object): self._assert_strict_value(value) super(_StrictDictMixin, self).setdefault(key, value) -def update(self, *a, **kw): -if isinstance(a, dict): -for k, v in a.items(): -self._assert_strict_key(k) -self._assert_strict_value(v) -for k, v in kw.items(): +def update(self, *args, **kwargs): +for k, v in kwargs.items(): self._assert_strict_key(k) self._assert_strict_value(v) -super(_StrictDictMixin, self).update(*a, **kw) +super(_StrictDictMixin, self).update(*args, **kwargs) @classmethod def _assert_strict_key(cls, key): -if not isinstance(key, cls._key_cls): +if cls._key_cls is not None and not isinstance(key, cls._key_cls): raise exceptions.StorageError("Key type was set strictly to {0}, but was {1}".format( cls._key_cls, type(key) )) @classmethod def _assert_strict_value(cls, value): -if not isinstance(value, cls._value_cls): +if cls._value_cls is not None and not isinstance(value, cls._value_cls): raise exceptions.StorageError("Value type was set strictly to {0}, but was {1}".format( cls._value_cls, type(value) )) @@ -159,21 +150,21 @@ class _StrictListMixin(object): self._assert_item(value) super(_StrictListMixin, self).__setitem__(index, value) -def append(self, x): -self._assert_item(x) -super(_StrictListMixin, self).append(x) +def append(self, item): +self._assert_item(item) +super(_StrictListMixin, self).append(item) -def extend(self, x): -self._assert_item(x) -super(_StrictListMixin, self).extend(x) +def extend(self, item): +self._assert_item(item) +super(_StrictListMixin, self).extend(item) -def insert(self, i, x): -self._assert_item(x) -super(_StrictListMixin, self).insert(i, x) +def insert(self, index, item): +self._assert_item(item) +super(_StrictListMixin, self).insert(index, item) @classmethod def _assert_item(cls, item): -if not isinstance(item, cls._item_cls): +if cls._item_cls is not None and not isinstance(item, cls._item_cls): raise exceptions.StorageError("Key type was set strictly to {0}, but was {1}".format( cls._item_cls, type(item) )) @@ -197,43 +188,52 @@ class _MutableList(mutable.MutableList): except ValueError as e: raise exceptions.StorageError('SQL Storage error: {0}'.format(str(e))) -_strict_dict_id = namedtuple('strict_dict_id', 'key_cls, value_cls') -_strict_map = {} - - -def
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-66-Convert-custom-parser-fields-into-sqla-based-fields c0fdc03f0 -> d05373b0e (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d05373b0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d05373b0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d05373b0 Branch: refs/heads/ARIA-66-Convert-custom-parser-fields-into-sqla-based-fields Commit: d05373b0e101040e86609dcf9fd4409ff77b9a7e Parents: 64a393e Author: mxmrlvAuthored: Mon Jan 30 17:05:14 2017 +0200 Committer: mxmrlv Committed: Mon Jan 30 17:37:47 2017 +0200 -- aria/storage/type.py | 125 +- tests/storage/__init__.py| 19 +++--- tests/storage/test_structures.py | 26 +++ 3 files changed, 85 insertions(+), 85 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d05373b0/aria/storage/type.py -- diff --git a/aria/storage/type.py b/aria/storage/type.py index 1b28f33..6c8f241 100644 --- a/aria/storage/type.py +++ b/aria/storage/type.py @@ -12,6 +12,7 @@ # 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. + import json from collections import namedtuple from types import NoneType @@ -21,10 +22,9 @@ from sqlalchemy import ( VARCHAR, event ) - from sqlalchemy.ext import mutable -from . import exceptions +from aria.storage import exceptions class _MutableType(TypeDecorator): @@ -64,10 +64,6 @@ class List(_MutableType): class _StrictDictMixin(object): -ANY_TYPE = 'any_type' - -_key_cls = ANY_TYPE -_value_cls = ANY_TYPE @classmethod def coerce(cls, key, value): @@ -95,26 +91,22 @@ class _StrictDictMixin(object): self._assert_strict_value(value) super(_StrictDictMixin, self).setdefault(key, value) -def update(self, *a, **kw): -if isinstance(a, dict): -for k, v in a.items(): -self._assert_strict_key(k) -self._assert_strict_value(v) -for k, v in kw.items(): +def update(self, *args, **kwargs): +for k, v in kwargs.items(): self._assert_strict_key(k) self._assert_strict_value(v) -super(_StrictDictMixin, self).update(*a, **kw) +super(_StrictDictMixin, self).update(*args, **kwargs) @classmethod def _assert_strict_key(cls, key): -if not isinstance(key, cls._key_cls): +if cls._key_cls is not None and not isinstance(key, cls._key_cls): raise exceptions.StorageError("Key type was set strictly to {0}, but was {1}".format( cls._key_cls, type(key) )) @classmethod def _assert_strict_value(cls, value): -if not isinstance(value, cls._value_cls): +if cls._value_cls is not None and not isinstance(value, cls._value_cls): raise exceptions.StorageError("Value type was set strictly to {0}, but was {1}".format( cls._value_cls, type(value) )) @@ -159,21 +151,21 @@ class _StrictListMixin(object): self._assert_item(value) super(_StrictListMixin, self).__setitem__(index, value) -def append(self, x): -self._assert_item(x) -super(_StrictListMixin, self).append(x) +def append(self, item): +self._assert_item(item) +super(_StrictListMixin, self).append(item) -def extend(self, x): -self._assert_item(x) -super(_StrictListMixin, self).extend(x) +def extend(self, item): +self._assert_item(item) +super(_StrictListMixin, self).extend(item) -def insert(self, i, x): -self._assert_item(x) -super(_StrictListMixin, self).insert(i, x) +def insert(self, index, item): +self._assert_item(item) +super(_StrictListMixin, self).insert(index, item) @classmethod def _assert_item(cls, item): -if not isinstance(item, cls._item_cls): +if cls._item_cls is not None and not isinstance(item, cls._item_cls): raise exceptions.StorageError("Key type was set strictly to {0}, but was {1}".format( cls._item_cls, type(item) )) @@ -197,43 +189,52 @@ class _MutableList(mutable.MutableList): except ValueError as e: raise exceptions.StorageError('SQL Storage error: {0}'.format(str(e))) -_strict_dict_id = namedtuple('strict_dict_id', 'key_cls, value_cls') -_strict_map = {} - - -def
[1/5] incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-44-Merge-parser-and-storage-models 0072cd64d -> 82d9be7d5 (forced update) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/82d9be7d/tests/storage/test_models.py -- diff --git a/tests/storage/test_models.py b/tests/storage/test_models.py deleted file mode 100644 index 2088676..000 --- a/tests/storage/test_models.py +++ /dev/null @@ -1,919 +0,0 @@ -# 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. -from datetime import datetime -from contextlib import contextmanager - -import pytest - -from aria import application_model_storage -from aria.storage import ( -exceptions, -sql_mapi, -) -from aria.storage.model import ( -DeploymentUpdateStep, -Blueprint, -Execution, -Task, -Plugin, -Deployment, -Node, -NodeInstance, -Relationship, -RelationshipInstance, -DeploymentUpdate, -DeploymentModification, -) - - -from tests import mock -from tests.storage import get_sqlite_api_kwargs, release_sqlite_storage - - -@contextmanager -def sql_storage(storage_func): -storage = None -try: -storage = storage_func() -yield storage -finally: -if storage: -release_sqlite_storage(storage) - - -def _empty_storage(): -return application_model_storage(sql_mapi.SQLAlchemyModelAPI, - api_kwargs=get_sqlite_api_kwargs()) - - -def _blueprint_storage(): -storage = _empty_storage() -blueprint = mock.models.get_blueprint() -storage.blueprint.put(blueprint) -return storage - - -def _deployment_storage(): -storage = _blueprint_storage() -deployment = mock.models.get_deployment(storage.blueprint.list()[0]) -storage.deployment.put(deployment) -return storage - - -def _deployment_update_storage(): -storage = _deployment_storage() -deployment_update = DeploymentUpdate( -deployment=storage.deployment.list()[0], -created_at=now, -deployment_plan={}, -) -storage.deployment_update.put(deployment_update) -return storage - - -def _node_storage(): -storage = _deployment_storage() -node = mock.models.get_dependency_node(storage.deployment.list()[0]) -storage.node.put(node) -return storage - - -def _nodes_storage(): -storage = _deployment_storage() -dependent_node = mock.models.get_dependent_node(storage.deployment.list()[0]) -dependency_node = mock.models.get_dependency_node(storage.deployment.list()[0]) -storage.node.put(dependent_node) -storage.node.put(dependency_node) -return storage - - -def _node_instances_storage(): -storage = _nodes_storage() -dependent_node = storage.node.get_by_name(mock.models.DEPENDENT_NODE_NAME) -dependency_node = storage.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) -dependency_node_instance = mock.models.get_dependency_node_instance(dependency_node) -dependent_node_instance = mock.models.get_dependent_node_instance(dependent_node) -storage.node_instance.put(dependency_node_instance) -storage.node_instance.put(dependent_node_instance) -return storage - - -def _execution_storage(): -storage = _deployment_storage() -execution = mock.models.get_execution(storage.deployment.list()[0]) -plugin = mock.models.get_plugin() -storage.execution.put(execution) -storage.plugin.put(plugin) -return storage - - -@pytest.fixture -def empty_storage(): -with sql_storage(_empty_storage) as storage: -yield storage - - -@pytest.fixture -def blueprint_storage(): -with sql_storage(_blueprint_storage) as storage: -yield storage - - -@pytest.fixture -def deployment_storage(): -with sql_storage(_deployment_storage) as storage: -yield storage - - -@pytest.fixture -def deployment_update_storage(): -with sql_storage(_deployment_update_storage) as storage: -yield storage - - -@pytest.fixture -def node_storage(): -with sql_storage(_node_storage) as storage: -yield storage - - -@pytest.fixture -def nodes_storage(): -with sql_storage(_nodes_storage) as storage: -yield storage - -
incubator-ariatosca git commit: wip [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/Relationship-ordering-significance-support d683352e8 -> f96047dd3 (forced update) wip Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/f96047dd Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/f96047dd Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/f96047dd Branch: refs/heads/Relationship-ordering-significance-support Commit: f96047dd3445ee7fa93ce732872a2a23ed97a535 Parents: c9ecc54 Author: mxmrlvAuthored: Tue Dec 27 16:42:57 2016 +0200 Committer: mxmrlv Committed: Sun Jan 1 16:24:59 2017 +0200 -- aria/storage/base_model.py | 68 + aria/storage/structure.py | 17 +-- 2 files changed, 70 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f96047dd/aria/storage/base_model.py -- diff --git a/aria/storage/base_model.py b/aria/storage/base_model.py index c7eb27c..454bc95 100644 --- a/aria/storage/base_model.py +++ b/aria/storage/base_model.py @@ -51,6 +51,7 @@ from sqlalchemy import ( Float, orm, ) +from sqlalchemy.ext.orderinglist import ordering_list from .structure import ModelMixin @@ -415,7 +416,13 @@ class RelationshipBase(ModelMixin): """ __tablename__ = 'relationships' -_private_fields = ['source_node_fk', 'target_node_fk'] +_private_fields = ['source_node_fk', 'target_node_fk', 'position'] + +position = Column(Integer) + +@declared_attr +def deployment_id(self): +return association_proxy('source_node', 'deployment_id') @declared_attr def source_node_fk(cls): @@ -423,8 +430,14 @@ class RelationshipBase(ModelMixin): @declared_attr def source_node(cls): -return cls.one_to_many_relationship('source_node_fk', - backreference='outbound_relationships') +return cls.one_to_many_relationship( +'source_node_fk', +backreference='outbound_relationships', +backref_kwargs=dict( +order_by=cls.position, +collection_class=ordering_list('position', count_from=0) +) +) @declared_attr def source_name(cls): @@ -432,11 +445,18 @@ class RelationshipBase(ModelMixin): @declared_attr def target_node_fk(cls): -return cls.foreign_key(NodeBase) +return cls.foreign_key(NodeBase, nullable=True) @declared_attr def target_node(cls): -return cls.one_to_many_relationship('target_node_fk', backreference='inbound_relationships') +return cls.one_to_many_relationship( +'target_node_fk', +backreference='inbound_relationships', +backref_kwargs=dict( +order_by=cls.position, +collection_class=ordering_list('position', count_from=0) +) +) @declared_attr def target_name(cls): @@ -503,35 +523,58 @@ class RelationshipInstanceBase(ModelMixin): __tablename__ = 'relationship_instances' _private_fields = ['relationship_storage_fk', 'source_node_instance_fk', - 'target_node_instance_fk'] + 'target_node_instance_fk', + 'position'] + +position = Column(Integer) @declared_attr def source_node_instance_fk(cls): -return cls.foreign_key(NodeInstanceBase) +return cls.foreign_key(NodeInstanceBase, nullable=True) @declared_attr def source_node_instance(cls): -return cls.one_to_many_relationship('source_node_instance_fk', - backreference='outbound_relationship_instances') +return cls.one_to_many_relationship( +'source_node_instance_fk', +backreference='outbound_relationship_instances', +backref_kwargs=dict( +order_by=cls.position, +collection_class=ordering_list('position', count_from=0) +) +) @declared_attr def source_node_instance_name(cls): +return association_proxy('source_node_instance', 'node_{0}'.format(cls.name_column_name())) + +@declared_attr +def source_node_name(cls): return association_proxy('source_node_instance', cls.name_column_name()) @declared_attr def target_node_instance_fk(cls): -return cls.foreign_key(NodeInstanceBase) +return cls.foreign_key(NodeInstanceBase, nullable=True) @declared_attr def target_node_instance(cls): -return