Skip to content

Add simplified Git fields on workers and worker versions

https://redmine.teklia.com/issues/5720

Closes #1500 (closed) by removing revision_id from CreateWorkerVersion.

  • Add three fields:

    • Worker.repository_url, a nullable CharField that will take the URL of the worker's Repository.
    • WorkerVersion.revision_url, a nullable CharField that will be the URL of the commit for this version.
    • WorkerVersion.tag, a nullable CharField obeying the same semantics as ModelVersion.tag.
  • Add a UniqueConstraint to make worker version tags unique per worker.

  • Write a data migration that:

    • For workers with repositories, sets repository_url to Worker.repository.url, which is doable in one straightforward .update();
    • For worker versions with revisions:
      • sets revision_url to the same value computed by the commit_url Python property, which is also doable in one .update() using arkindex.project.tools.RTrimChr and concatenation;
      • sets tag to the name of the first GitRef with the type Tag, ordered by descending name.
  • Add repository_url to the WorkerSerializer as a URLField, so that it is available in ListWorkers, RetrieveWorker, CreateWorker and [Partial]UpdateWorker.

  • Add revision_url to the WorkerVersionSerializer as a URLField, so that it is readable in ListWorkerVersions, RetrieveWorkerVersion, ListWorkerRuns, ListCorpusWorkerRuns, ListUserWorkerRuns, and RetrieveWorkerRun. It must not be editable with [Partial]UpdateWorkerVersion.

  • Add tag to the WorkerVersionSerializer, so that it is available in all the aforementioned endpoints. This one is writable in both CreateWorkerVersion and [Partial]UpdateWorkerVersion, and the unique constraint should be validated.

  • Replace revision_id in the WorkerVersionCreateSerializer with revision_url, to change CreateWorkerVersion.

    • When authenticated with Ponos task authentication, the revision_url is required.

    • When the worker has a repository_url set, the revision_url is required.

      This requirement is intentionally not enforced in [Partial]UpdateWorker. There could be cases where a worker first does not have a repo, then gets one, so there would be versions with and without revisions. But when a worker has a repo, we do require revisions.

    • Whether or not the worker has a repository_id set does not affect the endpoint anymore.

    • These constraints should be documented in the API.

  • Update WorkerRun.build_summary:

    • When there is a tag and a revision, use @ {tag} ({truncated_id}).
    • When there is a tag and no revision, use @ {tag} (version {version}).
    • When there is no tag, use the current displays of @ {truncated_id} or @ version {version}.
  • Verify your API changes using the schema diff tool.

Edited by Erwan Rouchet