Skip to content

Build WorkerConfiguration model and links

A new model arkindex.dataimport.models.WorkerConfiguration is needed:

  • UUID PK
  • string(250) name
  • JsonField configuration to store the configuration
  • string(32) configuration_hash to store the MD5 hash of the config
  • Foreign key worker towards a Worker (related name should be configurations)
  • usual created + updated fields

Constraints:

  • unique together on worker + configuration_hash
  • unique together on worker + name

Signals:

  • a pre_save signal must always update the configuration_hash from the configuration value

Foreign keys on other models:

  • FK configuration from WorkerRun towards WorkerConfiguration (related name worker_runs)
  • FK configuration from WorkerActivity towards WorkerConfiguration (related name worker_activities)

Admin:

  • add a dedicated ModelAdmin for this new model
  • add an inline to view configurations for a worker

Migration:

  • Do not migrate existing WorkerRun.config there, it will take time to build the other features

Expected database structure

classDiagram
    WorkerRun --> DataImport
    WorkerRun --> WorkerVersion
    WorkerRun --> WorkerConfiguration
    WorkerConfiguration <-- WorkerActivity
    WorkerConfiguration --> Worker
    WorkerVersion --> Worker
    WorkerActivity --> WorkerVersion
    WorkerActivity ..> DataImport
    WorkerActivity

    class WorkerActivity {
        +WorkerConfiguration config
        +State state
    }
    class WorkerConfiguration  {
        +ID_numeric pk
        +MD5 hash_of_config

        +string name
        +Worker worker
        +JSONFIeld config
        - unique(ID)
        - unique(hash_of_config, worker)
        - unique(name, worker)

    }
Edited by Bastien Abadie