Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Service Desk
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
tud-zih-energy
Slurm
Commits
f8113e66
Commit
f8113e66
authored
10 years ago
by
Morris Jette
Browse files
Options
Downloads
Patches
Plain Diff
Update job_submit lua examples
parent
a8026e5b
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
contribs/lua/job_submit.license.lua
+9
-45
9 additions, 45 deletions
contribs/lua/job_submit.license.lua
contribs/lua/job_submit.lua
+9
-7
9 additions, 7 deletions
contribs/lua/job_submit.lua
with
18 additions
and
52 deletions
contribs/lua/job_submit.license.lua
+
9
−
45
View file @
f8113e66
...
...
@@ -17,8 +17,10 @@ function _limit_license_cnt(orig_string, license_name, max_count)
return
0
end
i
,
j
,
val
=
string.find
(
orig_string
,
license_name
..
"%*(%d)"
)
-- if val ~= nil then log_info("name:%s count:%s", license_name, val) end
i
,
j
,
val
=
string.find
(
orig_string
,
license_name
..
"%:(%d)"
)
if
val
~=
nil
then
slurm
.
log_info
(
"name:%s count:%s"
,
license_name
,
val
)
end
if
val
~=
nil
and
val
+
0
>
max_count
then
return
1
end
...
...
@@ -32,15 +34,14 @@ end
--########################################################################--
function
slurm_job_submit
(
job_desc
,
part_list
,
submit_uid
)
setmetatable
(
job_desc
,
job_req_meta
)
local
bad_license_count
=
0
bad_license_count
=
_limit_license_cnt
(
job_desc
.
licenses
,
"lscratcha"
,
1
)
bad_license_count
=
_limit_license_cnt
(
job_desc
.
licenses
,
"lscratchb"
,
1
)
+
bad_license_count
bad_license_count
=
_limit_license_cnt
(
job_desc
.
licenses
,
"lscratchc"
,
1
)
+
bad_license_count
if
bad_license_count
>
0
then
log_info
(
"slurm_job_submit: for user %
d
, invalid licenses value: %s"
,
job_desc
.
user_id
,
job_desc
.
licenses
)
slurm
.
log_info
(
"slurm_job_submit: for user %
u
, invalid licenses value: %s"
,
job_desc
.
user_id
,
job_desc
.
licenses
)
return
slurm
.
ESLURM_INVALID_LICENSES
end
...
...
@@ -48,8 +49,6 @@ function slurm_job_submit ( job_desc, part_list, submit_uid )
end
function
slurm_job_modify
(
job_desc
,
job_rec
,
part_list
,
modify_uid
)
setmetatable
(
job_desc
,
job_req_meta
)
setmetatable
(
job_rec
,
job_rec_meta
)
local
bad_license_count
=
0
-- *** YOUR LOGIC GOES BELOW ***
...
...
@@ -57,48 +56,13 @@ function slurm_job_modify ( job_desc, job_rec, part_list, modify_uid )
bad_license_count
=
_limit_license_cnt
(
job_desc
.
licenses
,
"lscratchb"
,
1
)
+
bad_license_count
bad_license_count
=
_limit_license_cnt
(
job_desc
.
licenses
,
"lscratchc"
,
1
)
+
bad_license_count
if
bad_license_count
>
0
then
log_info
(
"slurm_job_modify: for job %u, invalid licenses value: %s"
,
job_rec
.
job_id
,
job_desc
.
licenses
)
slurm
.
log_info
(
"slurm_job_modify: for job %u, invalid licenses value: %s"
,
job_rec
.
job_id
,
job_desc
.
licenses
)
return
slurm
.
ESLURM_INVALID_LICENSES
end
return
0
end
--########################################################################--
--
-- Initialization code:
--
-- Define functions for logging and accessing slurmctld structures
--
--########################################################################--
log_info
=
slurm
.
log_info
log_verbose
=
slurm
.
log_verbose
log_debug
=
slurm
.
log_debug
log_err
=
slurm
.
error
log_user
=
slurm
.
log_user
job_rec_meta
=
{
__index
=
function
(
table
,
key
)
return
_get_job_rec_field
(
table
.
job_rec_ptr
,
key
)
end
}
job_req_meta
=
{
__index
=
function
(
table
,
key
)
return
_get_job_req_field
(
table
.
job_desc_ptr
,
key
)
end
,
__newindex
=
function
(
table
,
key
,
value
)
return
_set_job_req_field
(
table
.
job_desc_ptr
,
key
,
value
)
end
}
part_rec_meta
=
{
__index
=
function
(
table
,
key
)
return
_get_part_rec_field
(
table
.
part_rec_ptr
,
key
)
end
}
log_info
(
"initialized"
)
slurm
.
log_info
(
"initialized"
)
return
slurm
.
SUCCESS
This diff is collapsed.
Click to expand it.
contribs/lua/job_submit.lua
+
9
−
7
View file @
f8113e66
...
...
@@ -15,8 +15,8 @@
function
slurm_job_submit
(
job_desc
,
part_list
,
submit_uid
)
if
job_desc
.
account
==
nil
then
local
account
=
"***TEST_ACCOUNT***"
slurm
.
log_info
(
"slurm_job_submit: job from uid %
d
, setting default account value: %s"
,
submit_uid
,
account
)
slurm
.
log_info
(
"slurm_job_submit: job from uid %
u
, setting default account value: %s"
,
submit_uid
,
account
)
job_desc
.
account
=
account
end
-- If no default partition, set the partition to the highest
...
...
@@ -25,8 +25,10 @@ function slurm_job_submit(job_desc, part_list, submit_uid)
local
new_partition
=
nil
local
top_priority
=
-
1
local
last_priority
=
-
1
local
inx
=
0
for
name
,
part
in
pairs
(
part_list
)
do
-- slurm.log_info("part name[%d]:%s", i, part.name)
slurm
.
log_info
(
"part name[%d]:%s"
,
inx
,
part
.
name
)
inx
=
inx
+
1
if
part
.
flag_default
~=
0
then
top_priority
=
-
1
break
...
...
@@ -38,8 +40,8 @@ function slurm_job_submit(job_desc, part_list, submit_uid)
end
end
if
top_priority
>=
0
then
slurm
.
log_info
(
"slurm_job_submit: job from uid %
d
, setting default partition value: %s"
,
job_desc
.
user_id
,
new_partition
)
slurm
.
log_info
(
"slurm_job_submit: job from uid %
u
, setting default partition value: %s"
,
job_desc
.
user_id
,
new_partition
)
job_desc
.
partition
=
new_partition
end
end
...
...
@@ -50,8 +52,8 @@ end
function
slurm_job_modify
(
job_desc
,
job_rec
,
part_list
,
modify_uid
)
if
job_desc
.
comment
==
nil
then
local
comment
=
"***TEST_COMMENT***"
slurm
.
log_info
(
"slurm_job_modify: for job %u from uid %
d
, setting default comment value: %s"
,
job_rec
.
job_id
,
modify_uid
,
comment
)
slurm
.
log_info
(
"slurm_job_modify: for job %u from uid %
u
, setting default comment value: %s"
,
job_rec
.
job_id
,
modify_uid
,
comment
)
job_desc
.
comment
=
comment
end
...
...
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