Tomás Emilio Silva Ebensperger
03/31/2021, 1:38 PMnicholas
psycopg2
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 PMTomás Emilio Silva Ebensperger
04/01/2021, 5:29 PMnicholas
class 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)
nicholas
Task
class, and calling super(Instance, self).run()
to call the parent class run methodnicholas
Tomás Emilio Silva Ebensperger
04/01/2021, 5:37 PMTomás Emilio Silva Ebensperger
04/02/2021, 12:48 PM