Home › Forums › FABRIC General Questions and Discussion › How to use long-lived tokens in experiments
- This topic has 9 replies, 3 voices, and was last updated 4 months ago by Nishanth Shyamkumar.
-
AuthorPosts
-
June 5, 2024 at 1:47 pm #7055
When I try to use my generated long-lived token in an experiment, it fails with an Exception.
Digging into the Fabric source code, in slice_manager.py, there is a check for refresh_tokens, however the long lived token does not contain this json field, which is why it always fails. The __load_tokens function is pasted below:
def __load_tokens(self, refresh: bool = True): “”” Load Fabric Tokens from the tokens.json if it exists Otherwise, this is the first attempt, create the tokens and save them @note this function is invoked when reloading the tokens to ensure tokens from the token file are read instead of the local variables “”” # Load the tokens from the JSON if os.path.exists(self.token_location): print(“token path exists\n”) with open(self.token_location, ‘r’) as stream: self.tokens = json.loads(stream.read()) print(f”self.tokens is {self.tokens}”) refresh_token = self.get_refresh_token() else: # First time login, use environment variable to load the tokens refresh_token = os.environ.get(Constants.CILOGON_REFRESH_TOKEN) # Renew the tokens to ensure any project_id changes are taken into account if refresh and self.auto_refresh: if refresh_token is None: raise SliceManagerException(f”Unable to refresh tokens: no refresh token found!”) self.refresh_tokens(refresh_token=refresh_token) How can I use the long lived token without the Fablib code raising exceptions ?
June 5, 2024 at 2:19 pm #7057Hi Nishanth,
This issue has been fixed for a while now but is only available in Beyond Bleeding Edge Container.
Could you please use that? This should be available in the pypi with the next release.
Thanks,
Komal
June 12, 2024 at 5:08 pm #7093Hi Komal,
I am using fablib from within a Python program. Can you let me know which branch of fabrictestbed-extensions should I use to have this updated change? Is it the main branch? Or branch 1.7?
pip install git+https://github.com/fabric-testbed/fabrictestbed-extensions@main
June 12, 2024 at 10:19 pm #7098Please install from the main branch via the command you shared.
Thanks,
Komal
June 17, 2024 at 12:54 pm #7125Hi Komal,
Looking at the source code, the required change in slice_manager.py is not present on the main branch. It is available in the other branches: adv-res, llt and 1.7
Should I use one of these branches to use the long lived tokens?
Essentially:
pip install git+https://github.com/fabric-testbed/fabrictestbed@1.7June 22, 2024 at 4:12 pm #7164Hi Nishant,
Installing fablib from main branch should work. It is using the
fabrictestbed==1.5.9
dependency which has the fix.fabrictestbed==1.5.9
is built fromllt
branch. I will work on merging this branch to main as well.Thanks,
Koma
July 3, 2024 at 2:59 pm #7207Hi Komal,
I tried this and it still does not work. Here are the fabric packages in my environment:
[code]
pip list | grep fab │
fabric-credmgr-client 1.6.1 │
fabric_fim 1.6.1 │
fabric_fss_utils 1.5.1 │
fabric-orchestrator-client 1.6.1 │
fabrictestbed 1.6.9 │
fabrictestbed-extensions 1.6.5[/code]
The fabrictestbed is at 1.6.9, yet the slice_manager.py and specifically the __load_tokens still has the refresh token Exception check.
July 9, 2024 at 2:23 pm #7222We are deploying 1.7 next week which would contain a fix for this issue. Apologies for the inconvenince!
Thanks,
Komal
July 23, 2024 at 10:07 am #7280Hi Nishanth,
The fix for this issue is now available with
fabrictestbed-extensions==1.7.2
Thanks,
Komal
July 23, 2024 at 11:29 am #7283Thanks Komal, I tested it and it is working without any issues after the update.
-
AuthorPosts
- You must be logged in to reply to this topic.