Skip to content

Commit

Permalink
Remove implementation of legacy workflows (#2379)
Browse files Browse the repository at this point in the history
Note that the database models are kept in place as they will be removed
later, because it will require a migration that will drop the tables.
However, we want to include some functionality that allows the user to
dump the content for storage, before having the migration executed.
  • Loading branch information
sphuber authored Jan 11, 2019
1 parent 1e339c3 commit cd2b051
Show file tree
Hide file tree
Showing 81 changed files with 219 additions and 5,931 deletions.
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
aiida/backends/tests/cmdline/commands/test_node.py|
aiida/backends/tests/cmdline/commands/test_user.py|
aiida/backends/tests/cmdline/commands/test_work.py|
aiida/backends/tests/cmdline/commands/test_workflow.py|
aiida/backends/tests/common/test_datastructures.py|
aiida/backends/tests/computer.py|
aiida/backends/tests/control/test_computer_ctrl.py|
Expand All @@ -129,7 +128,6 @@
aiida/backends/tests/utils/fixtures.py|
aiida/backends/tests/work/class_loader.py|
aiida/backends/tests/work/daemon.py|
aiida/backends/tests/workflows.py|
aiida/backends/tests/work/job_processes.py|
aiida/backends/tests/work/persistence.py|
aiida/backends/tests/work/process.py|
Expand All @@ -147,7 +145,6 @@
aiida/backends/utils.py|
aiida/common/datastructures.py|
aiida/daemon/execmanager.py|
aiida/daemon/workflowmanager.py|
aiida/manage/backup/backup_base.py|
aiida/orm/authinfo.py|
aiida/orm/autogroup.py|
Expand Down Expand Up @@ -189,10 +186,8 @@
aiida/orm/implementation/django/node.py|
aiida/orm/implementation/django/user.py|
aiida/orm/implementation/django/utils.py|
aiida/orm/implementation/django/workflow.py|
aiida/orm/implementation/general/__init__.py|
aiida/orm/implementation/general/node.py|
aiida/orm/implementation/general/workflow.py|
aiida/orm/implementation/__init__.py|
aiida/orm/implementation/sqlalchemy/authinfo.py|
aiida/orm/implementation/sqlalchemy/backend.py|
Expand All @@ -202,15 +197,13 @@
aiida/orm/implementation/sqlalchemy/node.py|
aiida/orm/implementation/sqlalchemy/querytool.py|
aiida/orm/implementation/sqlalchemy/utils.py|
aiida/orm/implementation/sqlalchemy/workflow.py|
aiida/orm/__init__.py|
aiida/orm/importexport.py|
aiida/orm/node/process/calculation/calcjob.py|
aiida/orm/node.py|
aiida/orm/utils/__init__.py|
aiida/orm/utils/loaders.py|
aiida/orm/utils/remote.py|
aiida/orm/workflow.py|
aiida/parsers/exceptions.py|
aiida/parsers/__init__.py|
aiida/parsers/parser.py|
Expand Down Expand Up @@ -270,10 +263,6 @@
aiida/transport/plugins/test_all_plugins.py|
aiida/transport/plugins/test_local.py|
aiida/transport/plugins/test_ssh.py|
aiida/workflows/__init__.py|
aiida/workflows/test.py|
aiida/workflows/user/__init__.py|
aiida/workflows/wf_demo.py|
aiida/work/__init__.py|
aiida/work/job_processes.py|
utils/create_requirements.py|
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ include aiida/backends/tests/export_import_test_files/*.aiida
include aiida/backends/sqlalchemy/migrations/script.py.mako
include aiida/cmdline/templates/*.tpl
include aiida/common/additions/backup_script/backup_info.json.tmpl
include examples/testdata/qepseudos/*
include docs/source/images/*.png
include utils/*
include setup.json
Expand Down
50 changes: 0 additions & 50 deletions aiida/backends/djsite/cmdline.py

This file was deleted.

62 changes: 56 additions & 6 deletions aiida/backends/djsite/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,10 +1448,64 @@ def __str__(self):
self.objname, self.objpk, self.message)


# Issue 2380 will take care of dropping these models, which will have to be accompanied by a migration.
# The datastructures can then also be removed

class Enumerate(frozenset):
"""Custom implementation of enum.Enum."""

def __getattr__(self, name):
if name in self:
return six.text_type(name) # always return unicode in Python 2
raise AttributeError("No attribute '{}' in Enumerate '{}'".format(name, self.__class__.__name__))

def __setattr__(self, name, value):
raise AttributeError("Cannot set attribute in Enumerate '{}'".format(self.__class__.__name__))

def __delattr__(self, name):
raise AttributeError("Cannot delete attribute in Enumerate '{}'".format(self.__class__.__name__))


class WorkflowState(Enumerate):
pass


wf_states = WorkflowState((
'CREATED',
'INITIALIZED',
'RUNNING',
'FINISHED',
'SLEEP',
'ERROR'
))


class WorkflowDataType(Enumerate):
pass


wf_data_types = WorkflowDataType((
'PARAMETER',
'RESULT',
'ATTRIBUTE',
))


class WorkflowDataValueType(Enumerate):
pass


wf_data_value_types = WorkflowDataValueType((
'NONE',
'JSON',
'AIIDA',
))

wf_start_call = "start"
wf_exit_call = "exit"
wf_default_call = "none"
@python_2_unicode_compatible
class DbWorkflow(m.Model):
from aiida.common.datastructures import wf_states

uuid = m.UUIDField(default=get_new_uuid, unique=True)
ctime = m.DateTimeField(default=timezone.now, editable=False)
mtime = m.DateTimeField(auto_now=True, editable=False)
Expand Down Expand Up @@ -1607,8 +1661,6 @@ def __str__(self):

@python_2_unicode_compatible
class DbWorkflowData(m.Model):
from aiida.common.datastructures import wf_data_types, wf_data_value_types

parent = m.ForeignKey(DbWorkflow, related_name='data')
name = m.CharField(max_length=255, blank=False)
time = m.DateTimeField(default=timezone.now, editable=False)
Expand Down Expand Up @@ -1663,8 +1715,6 @@ def __str__(self):

@python_2_unicode_compatible
class DbWorkflowStep(m.Model):
from aiida.common.datastructures import wf_states, wf_default_call

parent = m.ForeignKey(DbWorkflow, related_name='steps')
name = m.CharField(max_length=255, blank=False)
user = m.ForeignKey(AUTH_USER_MODEL, on_delete=m.PROTECT)
Expand Down
49 changes: 13 additions & 36 deletions aiida/backends/djsite/db/testbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import shutil
import os

from aiida.orm.implementation.django.backend import DjangoBackend
from aiida.backends.testimplbase import AiidaTestImplementation
from aiida.orm.implementation.django.backend import DjangoBackend

# Add a new entry here if you add a file with tests under aiida.backends.djsite.db.subtests
# The key is the name to use in the 'verdi test' command (e.g., a key 'generic'
Expand All @@ -42,41 +42,18 @@ def setUpClass_method(self):
self.backend = DjangoBackend()

def clean_db(self):
from aiida.backends.djsite.db.models import (DbComputer, DbUser, DbWorkflow, DbWorkflowStep, DbWorkflowData)

# Complicated way to make sure we 'unwind' all the relationships
# between workflows and their children.
DbWorkflowStep.calculations.through.objects.all().delete()
DbWorkflowStep.sub_workflows.through.objects.all().delete()
DbWorkflowData.objects.all().delete()
DbWorkflowStep.objects.all().delete()
DbWorkflow.objects.all().delete() # pylint: disable=no-member

# Delete groups
from aiida.backends.djsite.db.models import DbGroup

DbGroup.objects.all().delete()

# I first need to delete the links, because in principle I could
# not delete input nodes, only outputs. For simplicity, since
# I am deleting everything, I delete the links first
from aiida.backends.djsite.db.models import DbLink

DbLink.objects.all().delete()

# Then I delete the nodes, otherwise I cannot
# delete computers and users
from aiida.backends.djsite.db.models import DbNode

DbNode.objects.all().delete() # pylint: disable=no-member

DbUser.objects.all().delete() # pylint: disable=no-member

DbComputer.objects.all().delete()

from aiida.backends.djsite.db.models import DbLog

DbLog.objects.all().delete()
from aiida.backends.djsite.db import models

# I first need to delete the links, because in principle I could not delete input nodes, only outputs.
# For simplicity, since I am deleting everything, I delete the links first
models.DbLink.objects.all().delete()

# Then I delete the nodes, otherwise I cannot delete computers and users
models.DbNode.objects.all().delete() # pylint: disable=no-member
models.DbUser.objects.all().delete() # pylint: disable=no-member
models.DbComputer.objects.all().delete()
models.DbLog.objects.all().delete()
models.DbGroup.objects.all().delete()

# Note this is has to be a normal method, not a class method
def tearDownClass_method(self):
Expand Down
47 changes: 0 additions & 47 deletions aiida/backends/sqlalchemy/cmdline.py

This file was deleted.

6 changes: 4 additions & 2 deletions aiida/backends/sqlalchemy/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from __future__ import print_function
from __future__ import with_statement
from __future__ import absolute_import

from alembic import context
from aiida.backends.settings import IN_DOC_MODE

Expand All @@ -23,12 +24,12 @@
from aiida.backends.sqlalchemy.models.node import DbComputer, DbLink, DbNode
from aiida.backends.sqlalchemy.models.settings import DbSetting
from aiida.backends.sqlalchemy.models.user import DbUser
from aiida.backends.sqlalchemy.models.workflow import (
DbWorkflow, DbWorkflowData, DbWorkflowStep)
from aiida.backends.sqlalchemy.models.workflow import DbWorkflow
from aiida.common.exceptions import DbContentError
from aiida.backends.sqlalchemy.models.base import Base
target_metadata = Base.metadata


def run_migrations_offline():
"""Run migrations in 'offline' mode.
Expand Down Expand Up @@ -73,6 +74,7 @@ def run_migrations_online():
with context.begin_transaction():
context.run_migrations()


if not IN_DOC_MODE:
if context.is_offline_mode():
run_migrations_offline()
Expand Down
Loading

0 comments on commit cd2b051

Please sign in to comment.