Re: [modeller_usage] Use $SGE_TASK_ID in the python script
To: "Modeller Caretaker" <>, "modeller_usage" <>
Subject: Re: [modeller_usage] Use $SGE_TASK_ID in the python script
From: "ZHANG Cheng" <>
Date: Thu, 13 May 2021 18:30:27 +0100
Feedback-id: webmail:qq.com:bgforeign:bgforeign11
Hi, I got the solution, it should be
task_id = os.environ["JOB_ID"]
------------------ Original ------------------
From: "ZHANG Cheng" <>;
Date: Fri, May 14, 2021 00:20 AM
To: "Modeller Caretaker"<>;"modeller_usage"<>;
Subject: Re: [modeller_usage] Use $SGE_TASK_ID in the python script
I tried this,
task_id = os.environ["SGE_TASK_ID"]
print(task_id)
But I got "undefined" printed out.
------------------ Original ------------------
From: "Modeller Caretaker" <>;
Date: Fri, May 14, 2021 00:15 AM
To: "ZHANG Cheng"<>;"modeller_usage"<>;
Subject: Re: [modeller_usage] Use $SGE_TASK_ID in the python script
On 5/13/21 8:05 AM, ZHANG Cheng wrote: > random_integer = int(-1*str($SGE_TASK_ID)[-4:]) > ^ > SyntaxError: invalid syntax > > So is that possible to use the job ID (e.g. 7172646) as an variable in > the python environment? Thank you!
A simple Google search tells you the answer; here's one hit: https://www.askpython.com/python/environment-variables-in-python
In your case, you want to use os.environ['SGE_TASK_ID'] rather than $SGE_TASK_ID.
Ben Webb, Modeller Caretaker -- https://salilab.org/modeller/ Modeller mail list: https://salilab.org/mailman/listinfo/modeller_usage