Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
5fd2f921
Commit
5fd2f921
authored
1 year ago
by
Daniel Nemergut
Browse files
Options
Downloads
Patches
Plain Diff
Made a new capability to support queueing curator workflow requests
parent
881cadce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1605
Merge 2.8.2.3 work to main
,
!1493
WS-1893 curator workflow
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shared/workspaces/alembic/versions/5939146da7bb_add_curator_capability.py
+172
-0
172 additions, 0 deletions
...s/alembic/versions/5939146da7bb_add_curator_capability.py
with
172 additions
and
0 deletions
shared/workspaces/alembic/versions/5939146da7bb_add_curator_capability.py
0 → 100644
+
172
−
0
View file @
5fd2f921
"""
add curator capability
Revision ID: 5939146da7bb
Revises: 3eae1178cace
Create Date: 2023-10-23 22:04:43.801226
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
'
5939146da7bb
'
down_revision
=
'
3eae1178cace
'
branch_labels
=
None
depends_on
=
None
wf_name
=
"
curator
"
def
upgrade
():
op
.
execute
(
f
"""
INSERT INTO capabilities (capability_name, max_jobs)
VALUES (E
'
{
wf_name
}
'
, 10)
"""
)
op
.
execute
(
f
"""
INSERT INTO capability_state_machines (capability_name, machine_type, associated_workflows)
VALUES (E
'
{
wf_name
}
'
,
'
simple
'
,
'
{{
"
workflow_name
"
:
"
{
wf_name
}
"
}}
'
)
"""
)
# This capability will have the same states, transitions, and actions as the download capability
op
.
execute
(
f
"""
INSERT INTO capability_states
SELECT E
'
{
wf_name
}
'
, state
FROM capability_states
WHERE capability_name =
'
download
'
"""
)
op
.
execute
(
f
"""
INSERT INTO capability_state_transitions (capability_name, from_state, pattern, to_state)
SELECT E
'
{
wf_name
}
'
, from_state, pattern, to_state
FROM capability_state_transitions
WHERE capability_name =
'
download
'
;
"""
)
# Making these explicit to grab the correct transition_ids
op
.
execute
(
f
"""
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Start
'
AND to_state=
'
Queued
'
),
'
QueueWorkflow
'
, E
'
{
wf_name
}
'
);
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Start
'
AND to_state=
'
Queued
'
),
'
SendNotification
'
,
'
{{
"
template
"
:
"
workflow_submitted
"
}}
'
);
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Queued
'
AND to_state=
'
Executing
'
),
'
ExecuteWorkflow
'
, E
'
{
wf_name
}
'
);
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Queued
'
AND to_state=
'
Cancelled
'
),
'
SendMessage
'
,
'
capability_cancelled
'
);
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Executing
'
AND to_state=
'
Complete
'
),
'
SendMessage
'
,
'
execution_complete
'
);
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Executing
'
AND to_state=
'
Complete
'
),
'
SendNotification
'
,
'
{{
"
template
"
:
"
workflow_complete
"
,
"
send_to_qa
"
: false}}
'
);
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Executing
'
AND to_state=
'
Error
'
),
'
SendMessage
'
,
'
execution_error
'
);
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Executing
'
AND to_state=
'
Error
'
),
'
SendNotification
'
,
'
{{
"
template
"
:
"
workflow_failed
"
,
"
send_to_qa
"
: false}}
'
);
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Executing
'
AND to_state=
'
Cancelled
'
),
'
Cancel
'
, E
'
{
wf_name
}
'
);
INSERT INTO capability_state_actions (transition_id, action_type, arguments)
VALUES (
(SELECT transition_id FROM capability_state_transitions
WHERE capability_name=E
'
{
wf_name
}
'
AND from_state=
'
Executing
'
AND to_state=
'
Cancelled
'
),
'
SendMessage
'
,
'
capability_cancelled
'
);
"""
)
def
downgrade
():
op
.
execute
(
f
"""
DELETE FROM capability_state_actions WHERE transition_id IN (
SELECT transition_id FROM capability_state_transitions WHERE capability_name =
{
wf_name
}
)
"""
)
op
.
execute
(
f
"""
DELETE FROM capability_state_transitions WHERE capability_name =
{
wf_name
}
"""
)
op
.
execute
(
f
"""
DELETE FROM capability_states WHERE capability_name =
{
wf_name
}
"""
)
op
.
execute
(
f
"""
DELETE FROM capability_state_machines WHERE capability_name =
{
wf_name
}
"""
)
op
.
execute
(
f
"""
DELETE FROM capabilities WHERE capability_name =
{
wf_name
}
"""
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment