sofarocean / sofar-api-client-python

Python Client for Wavefleet
Apache License 2.0
7 stars 5 forks source link

custom_token isn't being passed to child Spotter workers #13

Open g-mo opened 2 years ago

g-mo commented 2 years ago

When using custom_token to initialize SofarApi, the custom token does not get passed into the Spotter workers. The Spotter workers will then each create their own instance of SofarApi that uses the WF_API_TOKEN environment variable, possibly resulting in failed queries due to using a wrong or missing token

pieterbartsmit commented 2 years ago

@g-mo this is a rather tricky issue it seems. It is not always obvious when a new instance of the connection class gets created, and when the updated token needs to be passed.

From a user perspective- I am inclined to not tie a token to an object instance, but make it a global property instead. The case where you would want to have multiple connections with different keys seems somewhat niche- and it seems more intuitive to me that once a User sets a new Token - the get_token function just returns that token.

Complication is that currently tokens are also stored in the header parts of the sofarconnection objects, which would not automatically get updated on a change of state. Maybe adding the token to the header should be left to the point where we do a call to get/post etc.?

pieterbartsmit commented 2 years ago

@tcj for visibility