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
97497c18
Commit
97497c18
authored
4 years ago
by
Nathan Hertz
Browse files
Options
Downloads
Patches
Plain Diff
Added from_file constructor to Capability; cleaned up imports and added
a couple empty classes in an attempt to thwart circular importing
parent
e6e5f8cc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
shared/workspaces/src/workspaces/helpers.py
+14
-3
14 additions, 3 deletions
shared/workspaces/src/workspaces/helpers.py
shared/workspaces/src/workspaces/schema.py
+26
-5
26 additions, 5 deletions
shared/workspaces/src/workspaces/schema.py
with
40 additions
and
8 deletions
shared/workspaces/src/workspaces/helpers.py
+
14
−
3
View file @
97497c18
from
__future__
import
annotations
from
enum
import
Enum
,
auto
from
typing
import
Optional
,
List
,
Iterator
from
__future__
import
annotations
from
.capability_interfaces
import
ParameterIF
,
CapabilityStepIF
,
CapabilitySequenceIF
from
.product_interfaces
import
FutureProductIF
class
CapabilityStep
:
class
CapabilityStep
(
CapabilityStepIF
)
:
"""
Class that represents a step in a capability sequence. A step is of a certain type and
certain step types can have a value
...
...
@@ -20,7 +23,7 @@ class CapabilityStep:
return
f
'
{
self
.
step_type
.
name
}
'
class
CapabilitySequence
:
class
CapabilitySequence
(
CapabilitySequenceIF
)
:
"""
Class that represents a capability sequence with a list of steps
"""
...
...
@@ -49,6 +52,14 @@ class CapabilitySequence:
return
'
,
'
.
join
(
self
)
class
Parameter
(
ParameterIF
):
pass
class
FutureProduct
(
FutureProductIF
):
pass
class
CapabilityStepType
(
Enum
):
"""
Enum that specifies the types of CapabilitySteps that are possible
...
...
This diff is collapsed.
Click to expand it.
shared/workspaces/src/workspaces/schema.py
+
26
−
5
View file @
97497c18
...
...
@@ -13,7 +13,9 @@ from sqlalchemy import create_engine
from
sqlalchemy.orm
import
relationship
,
sessionmaker
from
sqlalchemy.ext.declarative
import
declarative_base
from
.capability_interfaces
import
ParameterIF
from
.capability_interfaces
import
CapabilityIF
,
CapabilityRequestIF
,
CapabilityExecutionIF
,
\
CapabilitySequenceIF
,
ParameterIF
from
.helpers
import
CapabilityStepType
,
CapabilityStep
,
CapabilitySequence
from
.product_interfaces
import
FutureProductIF
...
...
@@ -134,7 +136,7 @@ class CapabilityEvent:
Base
=
declarative_base
()
class
Capability
(
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
...
...
@@ -145,21 +147,40 @@ class Capability(Base):
steps
=
sa
.
Column
(
'
capability_steps
'
,
sa
.
String
)
max_jobs
=
sa
.
Column
(
'
max_jobs
'
,
sa
.
Integer
)
@classmethod
def
from_file
(
cls
,
filename
):
self
=
cls
()
self
.
name
,
self
.
max_jobs
,
self
.
steps
=
cls
.
parse_capability_file
(
filename
)
return
self
@staticmethod
def
parse_capability_file
(
filename
:
str
)
->
tuple
[
str
,
int
,
CapabilitySequenceIF
]:
with
open
(
filename
,
'
r
'
)
as
f
:
name
,
max_jobs
=
f
.
readline
().
split
(
'
'
)
steps
=
[]
for
line
in
f
.
readlines
():
step_type
,
step_value
=
line
.
split
(
'
'
)
steps
.
append
(
CapabilityStep
(
CapabilityStepType
.
from_string
(
step_type
),
step_value
))
return
name
,
int
(
max_jobs
),
CapabilitySequence
(
steps
)
def
create_request
(
self
,
parameters
:
ParameterIF
,
future_products
:
FutureProductIF
,
versions
:
str
):
"""
Create a new request for this capability with specific options
FIXME: Future products needs a string representation
"""
return
CapabilityRequest
(
capability
=
self
.
id
,
parameters
=
parameters
.
json
(),
future_products
=
future_products
,
future_products
=
str
(
future_products
)
,
versions
=
versions
)
class
CapabilityRequest
(
Base
):
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
...
...
@@ -178,7 +199,7 @@ class CapabilityRequest(Base):
versions
=
sa
.
Column
(
'
versions
'
,
sa
.
String
)
class
CapabilityExecution
(
Base
):
class
CapabilityExecution
(
Base
,
CapabilityExecutionIF
):
"""
Schema representation of a capability request
'
s execution record
"""
...
...
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