Skip to content

Commit

Permalink
Fix burst typecast. (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoTavares committed Aug 12, 2020
1 parent 4e8b255 commit e29edf3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cueadmin/cueadmin/common.py
Expand Up @@ -204,8 +204,10 @@ def getParser():
sub.add_argument("-size", action="store", nargs=3, metavar="SHOW ALLOC SIZE",
help="Set the guaranteed number of cores.")
sub.add_argument("-burst", action="store", nargs=3, metavar="SHOW ALLOC BURST",
help="Set the number of burst cores. Use the percent sign to indicate a "
"percentage of the subscription size instead of a hard size.")
help="Set the number of burst cores for a subscription passing: "
" show allocation value"
"Use the percent sign in value to indicate a percentage "
"of the subscription size instead of a hard size.")
#
# Host
#
Expand Down Expand Up @@ -798,15 +800,15 @@ def setUpState(hosts_):

elif args.size:
sub_name = "%s.%s" % (args.size[1], args.size[0])
opencue.api.findSubscription(sub_name).setSize(float(args.size[2]))
opencue.api.findSubscription(sub_name).setSize(int(args.size[2]))

elif args.burst:
sub_name = "%s.%s" % (args.burst[1], args.burst[0])
sub = opencue.api.findSubscription(sub_name)
burst = args.burst[2]
if burst.find("%") !=-1:
if burst.find("%") != -1:
burst = int(sub.data.size + (sub.data.size * (int(burst[0:-1]) / 100.0)))
sub.setBurst(float(burst))
sub.setBurst(int(burst))


def createAllocation(fac, name, tag):
Expand Down
2 changes: 2 additions & 0 deletions pycue/opencue/wrappers/subscription.py
Expand Up @@ -44,11 +44,13 @@ def get(self, id):
return Subscription(response.subscription)

def setSize(self, size):
assert (isinstance(size, int)), "size is not expected type: int"
self.stub.SetSize(
subscription_pb2.SubscriptionSetSizeRequest(subscription=self.data, new_size=size),
timeout=Cuebot.Timeout)

def setBurst(self, burst):
assert (isinstance(burst, int)), "burst is not expected type: int"
self.stub.SetBurst(
subscription_pb2.SubscriptionSetBurstRequest(subscription=self.data, burst=burst),
timeout=Cuebot.Timeout)
Expand Down

0 comments on commit e29edf3

Please sign in to comment.