# Set 'max\_run\_subjobs' job array property in a queuejob hook

**URL:** <https://community.openpbs.org/t/set-max-run-subjobs-job-array-property-in-a-queuejob-hook/2859>\
**Category:** Developers\
**Created:** [November 17, 2021, 12:31pm UTC](https://community.openpbs.org/t/set-max-run-subjobs-job-array-property-in-a-queuejob-hook/2859 "2021-11-17T12:31:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![theunforgiven](https://avatars.discourse-cdn.com/v4/letter/t/e480ec/32.png) [@theunforgiven](https://community.openpbs.org/u/theunforgiven)\
**Post date:** [November 17, 2021, 12:31pm UTC](https://community.openpbs.org/t/set-max-run-subjobs-job-array-property-in-a-queuejob-hook/2859/1 "2021-11-17T12:31:27Z")

</div>

I am trying to set the a `max_run_subjobs` job array property for a `queuejob` hook .

According to the documentation manual:

> You can set a limit on the number of simultaneously running subjobs from any one array job by setting the job’s `max_run_subjobs` attribute, either via `qalter -Wmax_run_subjobs=<new value> <job ID>`, or in a `queuejob` or `modifyjob` hook.

However , the manual on hooks makes no reference to this field.

I would expect to be able to set this property like:  
`pbs.event().job.max_run_subjobs = n`

So how am I able to set `max_run_subjobs` for a job array during an event hook ?

---

<div class="post-metadata">

**Author:** ![smgoosen](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@smgoosen](https://community.openpbs.org/u/smgoosen)\
**Post date:** [November 17, 2021, 8:13pm UTC](https://community.openpbs.org/t/set-max-run-subjobs-job-array-property-in-a-queuejob-hook/2859/2 "2021-11-17T20:13:37Z")

</div>

These two array attributes are readable/settable in a queuejob hook (for example):

qsub -l select=1 -J 1-10%5 …/job.script

pbs.logmsg(pbs.LOG\_DEBUG, “array\_indices\_submitted value = {}”.format(j.array\_indices\_submitted))  
pbs.logmsg(pbs.LOG\_DEBUG, “max\_run\_subjobs value = {}”.format(j.max\_run\_subjobs))

11/17/2021 20:08:45;0006;Server@trn-smgoo;Hook;Server@trn-smgoo;array\_indices\_submitted value = 1-10  
11/17/2021 20:08:45;0006;Server@trn-smgoo;Hook;Server@trn-smgoo;max\_run\_subjobs value = 5

You should be able to set max\_run\_subjobs in a queuejob hook as you would any other job attribute.

---

<div class="post-metadata">

**Author:** ![theunforgiven](https://avatars.discourse-cdn.com/v4/letter/t/e480ec/32.png) [@theunforgiven](https://community.openpbs.org/u/theunforgiven)\
**Post date:** [November 18, 2021, 10:05am UTC](https://community.openpbs.org/t/set-max-run-subjobs-job-array-property-in-a-queuejob-hook/2859/3 "2021-11-18T10:05:14Z")

</div>

@smgoosen I am seeing something different.

I am submitting the following job:

```auto
qsub -l select=1 -J 1-2

```

And looking at job properties:

```auto
pbs.event().job.max_run_subjobs
...
AttributeError: '_job' object has no attribute 'max_run_subjobs'

```

Also inspecting the job properties, I get the following list:

```auto
['_readonly', '_rerun', '_delete', '_checkpointed', '_msmom', '_stdout_file', '_s
tderr_file', ' __module__', 'attributes', '_attributes_hook_set', ' __new__', ' __init__', ' __str__', ' __setattr__', 'rerun', 'delete', 'is_checkpointed', 'in_ms_mom', '
stdout_file', 'stderr_file', 'release_nodes', ' __dict__', ' __weakref__', ' __doc__', 'id', 'failed_mom_list', 'succeeded_mom_list', '_connect_server', 'Job_Name', 'Job
_Owner', 'resources_used', 'resources_used_acct', 'resources_used_update', 'job_state', 'queue', 'server', 'Account_Name', 'Checkpoint', 'ctime', 'depend', 'Error_Pat
h', 'exec_host', 'exec_host2', 'exec_host_acct', 'exec_host_orig', 'exec_vnode', 'exec_vnode_acct', 'exec_vnode_deallocated', 'exec_vnode_orig', 'Execution_Time', 'gr
oup_list', 'Hold_Types', 'interactive', 'Join_Path', 'Keep_Files', 'Mail_Points', 'Mail_Users', 'mtime', 'no_stdio_sockets', 'Output_Path', 'Priority', 'qtime', 'Remo
ve_Files', 'Rerunable', 'Resource_List', 'Resource_List_orig', 'Resource_List_acct', 'schedselect', 'schedselect_orig', 'stime', 'session_id', 'Shell_Path_List', 'san
dbox', 'jobdir', 'stagein', 'stageout', 'substate', 'User_List', 'Variable_List', 'euser', 'egroup', 'hashname', 'hop_count', 'queue_rank', 'queue_type', 'sched_hint'
, 'security', 'comment', 'cookie', 'alt_id', 'alt_id2', 'etime', 'reserve_start', 'reserve_end', 'reserve_duration', 'reserve_state', 'reserve_Tag', 'reserve_ID', 'la
st_context_refresh', 'gridname', 'umask', 'block', 'cred', 'run_count', 'accounting_id', 'eligible_time', 'accrue_type', 'sample_starttime', 'job_kill_delay', 'Stageo
ut_status', 'Exit_status', 'Submit_arguments', 'executable', 'argument_list', 'prov_vnode', 'array', 'array_id', 'array_index', 'array_state_count', 'array_indices_su
bmitted', 'array_indices_remaining', 'pset', 'estimated', 'node_set', 'history_timestamp', 'project', 'forward_x11_cookie', 'forward_x11_port', 'ptime', 'run_version'
, 'gui', 'topjob_ineligible', 'resources_released', 'resource_released_list', 'release_nodes_on_stageout', 'tolerate_node_failures', 'Submit_Host', 'credential_id', '
credential_validity', 'create_resv_from_job', '_other_', ' __repr__', ' __hash__', ' __getattribute__', ' __delattr__', ' __lt__', ' __le__', ' __eq__', ' __ne__', ' __gt__',
' __ge__', ' __reduce_ex__', ' __reduce__', ' __subclasshook__', ' __init_subclass__', ' __format__', ' __sizeof__', ' __dir__', ' __class__']

```

The property `max_run_subjobs` is not part of that list. So how are you able to access that attribute?

---

<div class="post-metadata">

**Author:** ![smgoosen](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@smgoosen](https://community.openpbs.org/u/smgoosen)\
**Post date:** [November 18, 2021, 2:58pm UTC](https://community.openpbs.org/t/set-max-run-subjobs-job-array-property-in-a-queuejob-hook/2859/4 "2021-11-18T14:58:49Z")

</div>

What version of PBS Pro are you running? max\_run\_subjobs was introduced in 2020.1 so if you’re using a version older than that it will not be available.

---

<div class="post-metadata">

**Author:** ![theunforgiven](https://avatars.discourse-cdn.com/v4/letter/t/e480ec/32.png) [@theunforgiven](https://community.openpbs.org/u/theunforgiven)\
**Post date:** [November 19, 2021, 9:07am UTC](https://community.openpbs.org/t/set-max-run-subjobs-job-array-property-in-a-queuejob-hook/2859/5 "2021-11-19T09:07:13Z")

</div>

@smgoosen so I am using OpenPBS v20.0.1 , which is the latest stable release.

---

<div class="post-metadata">

**Author:** ![smgoosen](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@smgoosen](https://community.openpbs.org/u/smgoosen)\
**Post date:** [November 19, 2021, 4:10pm UTC](https://community.openpbs.org/t/set-max-run-subjobs-job-array-property-in-a-queuejob-hook/2859/6 "2021-11-19T16:10:57Z")

</div>

OK, that’s the issue, that OpenPBS release did not have this feature merged yet when it was created. If you were to build from the current master it would have max\_run\_subjobs.

---

<div class="post-metadata">

**Author:** ![theunforgiven](https://avatars.discourse-cdn.com/v4/letter/t/e480ec/32.png) [@theunforgiven](https://community.openpbs.org/u/theunforgiven)\
**Post date:** [November 22, 2021, 11:02am UTC](https://community.openpbs.org/t/set-max-run-subjobs-job-array-property-in-a-queuejob-hook/2859/7 "2021-11-22T11:02:49Z")

</div>

@smgoosen thanks ! I think I am using the stable released version so that would explain it.
