Setting enviroment variable

Hello,

Is there a way to make PBS set (for jobs) environment variables depending on resources requested in the select statement, similar to ncpus => $NCPUS?

Creating a wrapper script to get the inputs from the user , creates the script, assign the enviroment varilable with the script $NCPUS, $MEM, $WALLTIME, $LICENSE_SERVER , $LD_LIBRARY_PATHs and qsub that script.created within the wrapper.

No, I mean creating the environments without users changing anything in their scripts etc, completely transparently. I guess the only option is a hook, right?

Yes, hooks would help here for sure.
converting the values into Variable_List.

Wouldn’t accessing pbs.event().job.Resource_List["ncpus"] etc. suffice?

Interestingly, job.Resource_List["ncpus"] does work, but I cannot access similarly a custom resource. Why is that?

OK, I see it in the Hooks guide, 5.2.4.1:

Hooks have more access to built-in resources than they do to custom resources. All hooks can read built-in resources.
All event hooks that run at the server can read all custom resources via pbs.event(), as well as via pbs.server(). How-
ever, hooks that run at the execution host can read custom resources only via pbs.server(). So for example if a job
requests a custom resource, a runjob hook can read the resource, but an execjob_begin hook cannot.

So, it sounds like the intended behavior, but I fail to understand why it was deemed desirable.

The 2024 Admin guide, in section 5.14.2.5 says

You can make it faster for execution hooks to read custom job resources. Execution hooks cannot read custom job resources via the event, only via the server. However, you can cache a copy of a custom job resource at the MoMs for faster local reading by execution hooks, by setting the m flag for the resource. The job resources that can be cached are found in the following job attributes:

  • exec_vnode
  • Resource_List
  • resources_used

Would this handle your use-case?

2 Likes

Great, it works! I wasn’t aware of this flag; in fact, I can’t find it documented. It appears neither in “Table 5-9: Resource Accumulation Flags” nor in “Table 5-11: Resource Permission Flags”. In addition to the section you cited, I see this flag mentioned under “7.4.1 Create Container Resources”, but without explaining its meaning.

1 Like