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
390eff57
Commit
390eff57
authored
4 years ago
by
Nathan Hertz
Browse files
Options
Downloads
Patches
Plain Diff
Added prototype implementations of the persistent classes that will be
present in the archive eventually
parent
4a1634eb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shared/workspaces/src/workspaces/schema.py
+76
-3
76 additions, 3 deletions
shared/workspaces/src/workspaces/schema.py
with
76 additions
and
3 deletions
shared/workspaces/src/workspaces/schema.py
+
76
−
3
View file @
390eff57
...
...
@@ -13,6 +13,9 @@ from sqlalchemy import create_engine
from
sqlalchemy.orm
import
relationship
,
sessionmaker
from
sqlalchemy.ext.declarative
import
declarative_base
from
workspaces.interfaces
import
CapabilityIF
,
CapabilityName
,
\
ProductLocator
,
CapabilityRequestIF
,
ParameterIF
,
CapabilityQueueIF
class
AbstractFile
:
"""
...
...
@@ -94,10 +97,80 @@ class WorkflowEvent:
self
.
retval
==
other
.
retval
Base
=
declarative_base
()
class
Capability
(
Base
,
CapabilityIF
):
"""
A capability, which is a particular workflow setup, intended to accept
a certain kind of product and some parameters and produce another product
FIXME: Needs to pull workflow steps, capability info, capability params, etc. from database
"""
__tablename__
=
'
capabilities
'
capability_name
=
sa
.
Column
(
'
capability_name
'
,
sa
.
String
,
primary_key
=
True
)
max_jobs
=
sa
.
Column
(
'
max_jobs
'
,
sa
.
Integer
)
def
__init__
(
self
,
name
:
CapabilityName
,
max_jobs
:
int
,
locators
:
List
[
ProductLocator
]):
self
.
name
=
name
self
.
max_jobs
=
max_jobs
self
.
locators
=
locators
self
.
request
=
self
.
create_request
(
self
.
locators
)
def
create_request
(
self
,
locators
:
List
[
ProductLocator
])
->
CapabilityRequestIF
:
# FIXME: Fill in correct parameter details
return
CapabilityRequest
(
capability
=
self
,
locators
=
locators
,
id
=
None
,
parameters
=
[],
files
=
[],
versions
=
[],
tickets
=
[],
queue
=
None
)
class
CapabilityRequest
(
Base
,
CapabilityRequestIF
):
"""
A capability request, which couples a capability to a product, representing
the expectation of a new product given a set of parameters
"""
id
=
sa
.
Column
(
'
request_id
'
,
sa
.
Integer
,
primary_key
=
True
)
capability
=
sa
.
Column
(
'
capability_name
'
,
sa
.
String
,
sa
.
ForeignKey
(
'
capabilities.capability_name
'
)
)
locators
=
sa
.
Column
(
'
product_locators
'
,
sa
.
String
)
# FIXME: Should this be type JSON or type String or even some other type
parameters
=
sa
.
Column
(
'
parameters
'
,
sa
.
JSON
)
files
=
sa
.
Column
(
'
files
'
,
sa
.
String
)
versions
=
sa
.
Column
(
'
versions
'
,
sa
.
String
)
# FIXME: 'tickets' table does not currently exist
tickets
=
sa
.
Column
(
'
tickets
'
,
sa
.
String
,
sa
.
ForeignKey
(
'
tickets.ticket_name
'
))
# FIXME: There might be a way to reduce the number of params here, which would be great
def
__init__
(
self
,
capability
:
CapabilityIF
,
locators
:
List
[
ProductLocator
],
parameters
:
List
[
ParameterIF
],
files
:
List
[
Path
],
versions
:
List
[
str
],
tickets
:
List
[
Ticket
],
queue
:
CapabilityQueueIF
,
id
:
int
=
None
,
):
self
.
capability
=
capability
self
.
locators
=
locators
self
.
parameters
=
parameters
self
.
files
=
files
self
.
versions
=
versions
self
.
tickets
=
tickets
self
.
queue
=
queue
self
.
id
=
id
class
Workflow
(
Base
):
"""
A Workflow is a suite of tasks defined by templates that must be
...
...
@@ -105,8 +178,8 @@ class Workflow(Base):
"""
__tablename__
=
'
workflows
'
workflow_name
=
sa
.
Column
(
'
workflow_name
'
,
sa
.
String
,
primary_key
=
True
)
templates
=
relationship
(
'
WorkflowTemplate
'
,
backref
=
'
workflow
'
)
requests
=
relationship
(
'
WorkflowRequest
'
,
backref
=
'
workflow
'
)
templates
=
relationship
(
'
WorkflowTemplate
'
,
backref
=
'
workflow
s
'
)
requests
=
relationship
(
'
WorkflowRequest
'
,
backref
=
'
workflow
s
'
)
def
__json__
(
self
,
request
):
return
{
'
workflow_name
'
:
self
.
workflow_name
,
'
templates
'
:
self
.
templates
}
...
...
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