Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hattivatti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
GDP-Public
hattivatti
Commits
05ac024c
Commit
05ac024c
authored
10 months ago
by
Benjamin Wingfield
Browse files
Options
Downloads
Patches
Plain Diff
add helm pydantic models
parent
1f4ca4bf
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
pyvatti/src/pyvatti/helm.py
+74
-0
74 additions, 0 deletions
pyvatti/src/pyvatti/helm.py
with
74 additions
and
0 deletions
pyvatti/src/pyvatti/helm.py
0 → 100644
+
74
−
0
View file @
05ac024c
import
pathlib
from
functools
import
lru_cache
from
typing
import
Optional
import
yaml
from
pydantic
import
BaseModel
,
Field
,
field_validator
from
.config
import
settings
@lru_cache
def
parse_value_template
():
values_template
=
pathlib
.
Path
(
settings
.
HELM_CHART_PATH
/
"
values.yaml
"
)
return
yaml
.
safe_load
(
values_template
.
read_text
())
def
check_gcp_bucket
(
name
:
str
)
->
str
:
if
not
name
.
startswith
(
"
gs://
"
):
raise
ValueError
(
"
Bucket name doesn
'
t start with gs://
"
)
return
name
def
valid_target_build
(
cls
,
target_build
:
str
)
->
str
:
good_builds
=
[
"
GRCh37
"
,
"
GRCh38
"
]
if
target_build
not
in
good_builds
:
raise
ValueError
(
f
"
Target build not in
{
good_builds
}
"
)
return
target_build
class
HelmNextflowValues
(
BaseModel
,
validate_assignment
=
True
):
"""
Represents nextflow configuration values that can be templated by helm
"""
workBucketPath
:
str
gcpProject
:
str
location
:
str
spot
:
bool
wave
:
bool
fusion
:
bool
check_bucket
=
field_validator
(
"
workBucketPath
"
)(
check_gcp_bucket
)
class
HelmJobValues
(
BaseModel
,
validate_assignment
=
True
):
"""
Represents workflow instance values that can be templated by helm
"""
min_overlap
:
float
=
Field
(
ge
=
0
,
le
=
1
)
pgs_id
:
Optional
[
str
]
=
Field
(
pattern
=
"
PGS[0-9]{6}
"
)
pgp_id
:
Optional
[
str
]
=
Field
(
pattern
=
"
PGP[0-9]{6}
"
)
trait_efo
:
Optional
[
str
]
target_build
:
str
format
:
str
outdir
:
str
check_bucket
=
field_validator
(
"
outdir
"
)(
check_gcp_bucket
)
check_build
=
field_validator
(
"
target_build
"
)(
valid_target_build
)
class
HelmValues
(
BaseModel
,
validate_assignment
=
True
):
"""
Represents all fields in the helm chart that can be templated
"""
baseImage
:
str
dockerTag
:
str
pullPolicy
:
str
towerToken
:
str
towerId
:
str
# do model these
nxf
:
HelmNextflowValues
job
:
HelmJobValues
json_input
:
str
# don't model this
serviceAccount
:
dict
HELM_VALUES
=
HelmValues
(
**
parse_value_template
())
This diff is collapsed.
Click to expand it.
Preview
0%
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