Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
job-pattern-rule-evaluation-wip
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PathoJobs
job-pattern-rule-evaluation-wip
Commits
102cf9a8
Commit
102cf9a8
authored
5 months ago
by
Alex Wiens
Browse files
Options
Downloads
Patches
Plain Diff
Prule: add quantity function for rules
parent
5a1ef9c9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/data-structures-and-functions.md
+20
-0
20 additions, 0 deletions
docs/data-structures-and-functions.md
prule/__init__.py
+15
-0
15 additions, 0 deletions
prule/__init__.py
with
35 additions
and
0 deletions
docs/data-structures-and-functions.md
+
20
−
0
View file @
102cf9a8
...
@@ -164,6 +164,26 @@ Parameters:
...
@@ -164,6 +164,26 @@ Parameters:
Computes linear regression over samples in time and returns the slope.
Computes linear regression over samples in time and returns the slope.
### Other functions
#### `quantity`
Creates Pint Quantity values.
Parameters:
*
value (str or other)
*
unit (str, optional)
Example:
```
> quantity('1 GB/s')
<class 'pint.Quantity'>
1.0 gigabyte / second
> quantity(5, 'GB/s')
<class 'pint.Quantity'>
5 gigabyte / second
```
## Rule format
## Rule format
...
...
This diff is collapsed.
Click to expand it.
prule/__init__.py
+
15
−
0
View file @
102cf9a8
...
@@ -344,6 +344,21 @@ def rule_prepare_input(parameters, rules, clusters, job_meta, job_data):
...
@@ -344,6 +344,21 @@ def rule_prepare_input(parameters, rules, clusters, job_meta, job_data):
#for jn in job_names:
#for jn in job_names:
# globals[jn] = True
# globals[jn] = True
def
quantity_create
(
value
,
unit
=
None
):
if
unit
==
None
:
if
type
(
value
)
==
str
:
return
unit_registry
.
parse_expression
(
value
)
else
:
raise
Exception
(
"
Unit creation: expected string, got {}
"
.
format
(
value
))
else
:
if
type
(
value
)
==
str
and
type
(
unit
)
==
str
:
return
unit_registry
.
parse_expression
(
value
+
"
"
+
unit
)
elif
type
(
unit
)
==
str
:
return
unit_registry
.
Quantity
(
value
,
unit_registry
.
parse_units
(
unit
))
else
:
raise
Exception
(
"
Unit creation: expected string for unit, got {}
"
.
format
(
unit
))
globals
[
"
quantity
"
]
=
quantity_create
# prepare job metadata
# prepare job metadata
job
=
JobMetadata
()
job
=
JobMetadata
()
# copy all attributes from json to job object
# copy all attributes from json to job object
...
...
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