Querying WLS license status
AnsweredHi,
I have a license through WLS. I am curious if, other than through WLS manager, I can query my license-related information via other methods. To clarity, things I hope to query can be, if I have any active sessions, and if so, the start and end time of my active sessions. By other methods, I mean maybe a Python license management API, which I can integrate to my own code when I kick off an optimization job, and returns some information I mentioned above. I can't find any information regarding this, other than through WLS manager, so I want to figure it out whether or not it is possible.
Thanks,
Yuzhou
-
Hi Yuzhou,
Does this help?
- Riley
0 -
Hi Riley,
Thanks for the information. Is this API the only one I can query information from? Can I, for example, query from a Python API?
Thanks,
Yuzhou
0 -
Hi Yuzhou,
Typically when there is a REST API provided you would appeal to the "requests" library to use it from Python, eg
import requests
import os
# Retrieves environment variables set for access ID
# and secret key (as written in your license file)
WLS_ACCESS_ID = os.environ["WLSACCESSID"]
WLS_SECRET = os.environ["WLSSECRET"]
# Set up the request headers
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"X-GUROBI-ACCESS-ID": WLS_ACCESS_ID,
"X-GUROBI-SECRET-KEY": WLS_SECRET,
}
# example: get information for the last token
url = "https://license.gurobi.com/manager/api/v1/tokens?length=1"
response = requests.get(url, headers=headers)
print(response.json())- Riley
0 -
Hi Riley,
I was able to use the resources you provided. Thank you very much for that!
I have a follow-up question. Can any of these be used to manage the license usage? For example, for whatever reason, I want to keep my license idle for certain period of time. Can this be achieved through this API?
Thanks,
Yuzhou
0 -
Hi Yuzhou,
I want to keep my license idle for certain period of time
I'm not sure what this means, can you elaborate?
- Riley
0 -
Hey Riley,
Sorry about the ambiguity. I realize this might be a Gurobi question, but let me clarify. My company is trying to build a software, whose heart is an optimization problem. The software can be used by all customers in theory, but since we have only one license, I want to create a program to allow only one customer at a time. Furthermore, the reason I want to keep the license idle for a certain period of time is because we may want to do a demo to someone, and during this period of time, we don't want any customers to be able to use the license.
Again, I feel like the program I am thinking about does not necessarily involve Gurobi, because I think I can rely on the information from the REST API you introduced to develop some logic. But still, I want to know if this API is purely a monitoring tool, or I can make some commands such that I can set, for example, "Active" attribute in REST API to be false or something.
Thanks,
Yuzhou
0 -
Hi Yuzhou,
You can use the REST API to request tokens, see /tokens at https://license.gurobi.com/manager/doc/api?type=generator, so it can do more than monitoring. It can't be used to end a token prematurely though - a token is associated with a duration which can't be changed once the token in generated.
This leads me to the next point. I don't think you need to appeal to the REST API to do what you want to do. If you want to make sure you have access to a token for a specified period of time then you can use the WLSTokenDuration parameter. I.e. if you have a 60 minute meeting with your customer then set WLSTokenDuration=60 (and perhaps WLSTokenRefresh=1) then there is no risk.
Note that since Verse is a commercial customer you can open a Support Request through our Help Center in the future and get assistance much faster than through the forum. You'll need to quote a Verse license ID though in the submission form otherwise your academic email address will lead to us redirecting you to the forum.
- Riley
0 -
Hi Riley,
To do what you suggest, do you mean the following:
import gurobipy as gp from gurobipy import GRB e = gp.Env("gurobi.log", params={'WLSTokenDuration': 60}) my_model = gp.Model('myModel', env=e)
Another clarification question I want to ask is session and token. My understanding is a valid token can trigger a session. As you mentioned, we can set token duration to certain value. However, from other communication channel, I was told a session has a minimum duration of 5 minutes. Is that true? Does that mean if an optimization job takes 1 minutes, we have to wait 4 minutes for that session to end, given no one else can access the session using the same token?
Thanks,
Yuzhou
0 -
Hi Yuzhou,
Yes that's it, or even better with context managers.
I was told a session has a minimum duration of 5 minutes
Yes, this is true. If you set WLSTokenDuration to a number less than 5, it will automatically be changed to 5.
Does that mean if an optimization job takes 1 minutes, we have to wait 4 minutes for that session to end, given no one else can access the session using the same token?
Yes, this is correct.
- Riley
0
Please sign in to leave a comment.
Comments
9 comments