Accessing launch_id attribute as part of Firetask

Hi All,

I have defined a custom firetask that inherits from FiretaskBase and I have added the FW to the LaunchPad and it was launched by a host successfully. As part of the Firetask code, there is a need to log metadata to a MongoDB database. Right now, one of the specs for the FW is a unique task_name that gets used to query from the collection in MongoDB. However, if later one I decide to rerun the same FW (with the rerun_fws lpad command), because it is using the same task_name field value, there is no way for me to easily parse the metadata of one launch from the other. So, in order to make the metadata unique across launches, I was thinking of logging the launch_id to the collection in MongoDB on top of the task_name. I was wondering whether it would be possible for me to access this as part of the Firetask itself.

Thanks.

The run_task(self, fw_spec) method gets some useful info in the two arguments, and you can print out self.to_dict() and fw_spec, but IIRC key metadata fields are not in there.

Maybe create a pull request that adds more metadata to the fw_spec?

Thanks for the reply and sorry for belated response. AJ let me know that there is an internal spec called _add_launchpad_and_fw_id that you can set to True as part of a FireWork and you will get the self.fw_id and self.launchpad accessible within the Firetask as a result. Hope that helps.