Tomás Emilio Silva Ebensperger
03/31/2021, 1:38 PMnicholas
03/31/2021, 2:25 PMpsycopg2
module as part of your flow's metadata, perhaps by referencing it outside of a task block. Since a flow's metadata (right now) needs to be pickleable so that it can be sent to the API, you'll need to make sure you're not inadvertently introducing non-pickleable objects.Tomás Emilio Silva Ebensperger
03/31/2021, 2:28 PMnicholas
04/01/2021, 5:35 PMclass CheckInstance(Task):
def list_instances(self, service, project, zone):
result = service.instances().list(project=project, zone=zone).execute()
return result["items"] if "items" in result else None
def run(self, credentials, instance, project, zone):
service = googleapiclient.discovery.build(
"compute", "v1", credentials=credentials
)
instances = self.list_instances(service, project, zone)
super(CheckInstance, self).run()
return any(i["name"] == instance for i in instances)
Task
class, and calling super(Instance, self).run()
to call the parent class run methodTomás Emilio Silva Ebensperger
04/01/2021, 5:37 PM