Skip to content

support 2nd parameter for lsb_guaranteedResourcePoolInfo #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions examples/disp_guaranteedResourcePool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from pythonlsf import lsf

def printGuaranteedResourcePools():
if lsf.lsb_init("test") > 0:
print("Unable to init LSF API")
return -1;

intp_size = lsf.copy_intp(0)
req = lsf.guaranteedResourcePoolInfoReq()
strArr = lsf.new_stringArray(1);
lsf.stringArray_setitem(strArr, 0, "");
req.poolsC = 0
req.poolNames = strArr;
req.queueName = ""
pp_ents = lsf.calloc_guaranteedResourcePoolEntPtrPtr()

rc = lsf.lsb_guaranteedResourcePoolInfo(req,pp_ents,intp_size)

if rc == -1 :
print('Call LSF API failed')
return -1;

ents = lsf.guaranteedResourcePoolEntPtrPtr_value(pp_ents)
size = lsf.intp_value(intp_size)

print("{} guaranteed resource pools in the cluster.".format(size))

for i in range(size) :
ent = lsf.guaranteedResourcePoolEntArray_getitem(ents, i)
print("Pool name: {}".format(ent.name))
print("Resource type: {}".format(ent.type))
print("Pool status: {}".format(ent.status))
print("Total resources in pool: {}".format(ent.total))
print("Free resources in pool: {}".format(ent.free))
currentHostList = lsf.char_p_p_to_pylist(ent.currentHosts,ent.currentHostsC)
print('Current hosts in the resource pool: ' + ' '.join(currentHostList))

lsf.delete_stringArray(strArr);
lsf.free_guaranteedResourcePoolEntPtrPtr(pp_ents);

return 0

if __name__ == '__main__':
print("LSF Clustername is : {}".format(lsf.ls_getclustername()))
printGuaranteedResourcePools()

5 changes: 4 additions & 1 deletion pythonlsf/lsf.i
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ int fclose(FILE *f);
%pointer_functions(long, longp)
%pointer_functions(LS_LONG_INT, LS_LONG_INT_POINTER)
%pointer_functions(limitInfoEnt *, limitInfoEntPtrPtr)
%pointer_functions(guaranteedResourcePoolEnt *, guaranteedResourcePoolEntPtrPtr)

%allocators(limitInfoEnt *, limitInfoEntPtrPtr);
%allocators(guaranteedResourcePoolEnt *, guaranteedResourcePoolEntPtrPtr);

%array_functions(int, intArray)
%array_functions(float, floatArray)
Expand All @@ -47,6 +49,7 @@ int fclose(FILE *f);
%array_functions(struct gpuRusage, gpuRusageArray)
#endif
%array_functions(LS_LONG_INT, LS_LONG_INTArray)
%array_functions(guaranteedResourcePoolEnt, guaranteedResourcePoolEntArray)

//helper function for transforming char** to python list
%inline %{
Expand Down Expand Up @@ -708,5 +711,5 @@ PyObject * get_pids_from_stream(struct jRusage * jrusage) {
}
return result;
}

%}