I tried this, 

task_id = os.environ["SGE_TASK_ID"]
print(task_id)

But I got "undefined" printed out.


------------------ Original ------------------
From: "Modeller Caretaker" <modeller-care@salilab.org>;
Date: Fri, May 14, 2021 00:15 AM
To: "ZHANG Cheng"<272699575@qq.com>;"modeller_usage"<modeller_usage@salilab.org>;
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
--
modeller-care@salilab.org             https://salilab.org/modeller/
Modeller mail list: https://salilab.org/mailman/listinfo/modeller_usage