# PP-425 to PP-434 - Server Periodic hooks support

**URL:** <https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278>\
**Category:** Developers\
**Created:** [October 10, 2016, 4:31pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278 "2016-10-10T16:31:33Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![jon](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/jon/32/23_2.png) [@jon](https://community.openpbs.org/u/jon)\
**Post date:** [October 19, 2016, 10:11pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/21 "2016-10-19T22:11:02Z")

</div>

On interface four I thought I saw run\_periodic\_hook instead of run periodic hook. Sorry for the confusion

---

<div class="post-metadata">

**Author:** ![bayucan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/bayucan/32/24_2.png) [@bayucan](https://community.openpbs.org/u/bayucan)\
**Post date:** [October 20, 2016, 7:52pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/22 "2016-10-20T19:52:00Z")

</div>

The server periodic hook EDD is looking good so far. Here are my comments:

interface 10: “true” should be “True” which is the Python value.

interface 13 shows something like:  
j1 = pbs.job()  
r1 = pbs.resv()  
r1.reserve\_start = int(time.time())+30  
r1.reserve\_duration = 600  
pbs.server().submit(r1)  
j1.queue = r1

–  
Problem here is The ‘queue’ attribute of job ‘j1’ is a pbs.queue type which is incompatible with ‘r1’ which is of pbs.resv type. Might be best to create a job function that associates a job to the reservation:

j1.add\_to\_reservation\_queue(r1)

NOTE: or whatever a good function name. I see the above call would result in submitting job ‘j1’ to the instantiated queue of reservation ‘r1’.

---

<div class="post-metadata">

**Author:** ![arungrover](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/arungrover/32/40_2.png) [@arungrover](https://community.openpbs.org/u/arungrover)\
**Post date:** [October 20, 2016, 9:18pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/23 "2016-10-20T21:18:21Z")

</div>

Thanks for reviewing Al!

I was hoping to somehow overload operator in queue object to accept the reservation as an input or do this using type identification. But, You are right that this is the way it has been designed for and I’ve not very sure at the code level to see how much of that is possible. It is just how I imagined the interface to be 🙂

So, I’ve changed the document to expose a method that can assign job to a reservation.  
Please have a look.

---

<div class="post-metadata">

**Author:** ![bayucan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/bayucan/32/24_2.png) [@bayucan](https://community.openpbs.org/u/bayucan)\
**Post date:** [October 20, 2016, 9:30pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/24 "2016-10-20T21:30:12Z")

</div>

Looks good, Arun! Thanks for making the change.

---

<div class="post-metadata">

**Author:** ![billnitzberg](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/billnitzberg/32/6_2.png) [@billnitzberg](https://community.openpbs.org/u/billnitzberg)\
**Post date:** [October 20, 2016, 11:49pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/25 "2016-10-20T23:49:12Z")

</div>

Regarding Interface 13 (version v. 20 in Confluence Page History):

I don’t think adding a new interface with a new name is warranted (or good). Rather than the new “add\_to\_resv()” method, I feel it is much more natural to “submit a job to a reservation” (as one uses qsub to submit jobs to reservations already.)

I suggest the method name should be “submit”. If an actual queue object is needed, the reservation object could expose its queue object (e.g., r1.queue).

---

<div class="post-metadata">

**Author:** ![bayucan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/bayucan/32/24_2.png) [@bayucan](https://community.openpbs.org/u/bayucan)\
**Post date:** [October 21, 2016, 7:51pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/26 "2016-10-21T19:51:25Z")

</div>

What Bill suggested is fine with me too.  
Another option is doing it from the reservation object, via an “add” method from the reservation object. For example:

j1 = pbs.job()

r1 = pbs.resv()  
r1.reserve\_start = int(time.time())+30  
r1.reserve\_duration = 600  
r1.add(j1) \<-- add a job to the reservation  
pbs.server().submit(r1)  
pbs.server.submit(j1)

* * *

But I’m fine in either case: j1.submit() or r1.add(j1)

---

<div class="post-metadata">

**Author:** ![billnitzberg](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/billnitzberg/32/6_2.png) [@billnitzberg](https://community.openpbs.org/u/billnitzberg)\
**Post date:** [October 21, 2016, 8:46pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/27 "2016-10-21T20:46:18Z")

</div>

Thanks @bayucan!

I was proposing that we do not invent a new method name, and “add()” would again be new. I think it is natural to simply use this existing submit() method name. So, to create a new job and submit it to a queue, one would:

j1 = pbs.job()  
j1.queue = pbs.server().queue(“workq”)  
pbs.server().submit(j1)

And to create a new reservation and submit a new job it it, one would:

r1 = pbs.resv()  
r1.reserve\_start = int(time.time())+30  
r1.reserve\_duration = 600  
pbs.server().submit(r1)

j1 = pbs.job()  
j1.queue = r1 // Alternatively, if we don’t want automatic type conversion, you could require: j1.queue = r1.Queue  
pbs.server().submit(j1)

---

<div class="post-metadata">

**Author:** ![bayucan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/bayucan/32/24_2.png) [@bayucan](https://community.openpbs.org/u/bayucan)\
**Post date:** [October 24, 2016, 7:24pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/28 "2016-10-24T19:24:11Z")

</div>

@billnitzberg : Ok, I’m fine with what you propose. In regards to submitting a job to a reservation, I prefer the ‘j1.queue = r1.queue’…

---

<div class="post-metadata">

**Author:** ![arungrover](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/arungrover/32/40_2.png) [@arungrover](https://community.openpbs.org/u/arungrover)\
**Post date:** [October 24, 2016, 8:57pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/29 "2016-10-24T20:57:56Z")

</div>

@bayucan, @billnitzberg I’ve made change to EDD as per your suggestions.

---

<div class="post-metadata">

**Author:** ![bayucan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/bayucan/32/24_2.png) [@bayucan](https://community.openpbs.org/u/bayucan)\
**Post date:** [October 24, 2016, 9:26pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/30 "2016-10-24T21:26:31Z")

</div>

@arungrover: I’m satisfied with the latest changes.

---

<div class="post-metadata">

**Author:** ![jon](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/jon/32/23_2.png) [@jon](https://community.openpbs.org/u/jon)\
**Post date:** [November 1, 2016, 4:56pm UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/31 "2016-11-01T16:56:41Z")

</div>

Looks good to me. I’m satisfied with the latest changes

---

<div class="post-metadata">

**Author:** ![arungrover](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/arungrover/32/40_2.png) [@arungrover](https://community.openpbs.org/u/arungrover)\
**Post date:** [December 22, 2016, 12:20am UTC](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278/32 "2016-12-22T00:20:02Z")

</div>

Listing down all the comments from Confluence page to forum. These comments are old and may not really relate to the latest discussion but for safekeeping I’m copying it here.

From: Al Bayucan  
_In interface 4, be sure to add that calling pbs.event().reject() will not stop the server periodic hook from executing in the next frequency cycle._

_In interface 5, you don’t need to create interface_ “create\_node”, “createreservation”, "_scheduling". You can just make use of existing: pbs.server().vnode_(\<new\_vnode\_name\>)_, pbs.server().resv_(\<new\_reservation\>), _and something like_ pbs.scheduling\_cyle(). _Note that we current have something like_ pbs.scheduler\_restart\_cycle().  
_Oct 08, 2016_

From: Al Bayucan  
_Or you can actually do something like pbs.server().set\_scheduling(True|False)_  
_Oct 08, 2016_

From: Al Bayucan  
_Same with interface 8, just make use of existing pbs.server().vnode() for defining a new node. Node here is just the natural vnode._  
_Oct 08, 2016_

From: Al Bayucan  
_So the interface could look like:_  
_vn = pbs.server().vnode(\<new\_vnode\_name\>) ← return a new vnode object to hang off of local pbs server._

_Now populate the vnode object with values:_  
_vn.resources\_avaliable[] =_

_Same with reservation:_  
_rv = pbs.server().resv() ← returns an reservation object to hang off the local pbs server._

_Populate the reservation object:_  
_rv.Resource\_List[] =_   
_Oct 08, 2016_

From: Arun Grover  
_Thanks for all your comments AL!_  
_I’ve made changes to Interface 4 and changed the interface scheduling to set\_scheduling._  
_I added new create\_vnode, create\_reservation interfaces specifically because pbs.server().vnode() can also be used to search for an existing vnode and if the vnode is not existing it can throw an exception/error. But if we use it to create a vnode as well then it will never throw an error thinking that it’s been called for a new vnode._  
_What do you think?_  
_Oct 10, 2016_

From: Jon Shelley  
_Arun,_  
_I agree with your assessment and would not want to lose the capability of throwing an error if the object (vnode in this case) does not exist. However, I would propose that we don’t use create_\* for each object that we want to add to the server. Instead, I would think that if we added two new methods called pbs.server().add() and pbs.server().remove(). These methods could add/remove a node, job, queue, reservation, custom resource, etc object to the server. This would allow us to present two simple methods to add and remove objects from the server. Thoughts?\_  
_Oct 10, 2016_

From: Jon Shelley  
_In interface 5 you do the following to get a vnode_  
_"n1 = pbs.server().vnode()"_  
_I would recommend that we do something like this instead_  
_"n1 = pbs.vnode()"_  
_Oct 11, 2016_

From: Al Bayucan  
_I like what Jon has proposed. We actually discussed it together. There’ll be some code adjustment needed to allow calling pbs.vnode(\<new\_node\_name\>), but it should be a straightforward fix._  
_Oct 11, 2016_

From: Arun Grover  
_I’m okay to have it in the way you have suggested. But, what is that we get out of it is what I need to understand._  
_I kept it under server because server is the one which is managing all the nodes inside of it, so it looked to me that it was logically correct to have it under server._  
_Who knows tomorrow one might just like a capability to search a vnode form a different server altogether (smile)_  
_Oct 11, 2016_

From: Jon Shelley  
_pbs.server().vnode() would be a vnode object from a server. pbs.vnode() would be a vnode object that has not yet been attached to the server. If we wanted to somehow down the road have a hook query another pbs server then I would imagine that we would do it something like pbs.server(“server name”). But I don’t see this as a very likely scenario at the moment but like you said it may be something we do down the road._

[Previous page](https://community.openpbs.org/t/pp-425-to-pp-434-server-periodic-hooks-support/278.md?page=1)
