title: How to reload tensorflow model in Google Cloud Run server?
body: <p>I have a webserver hosted on cloud run that loads a tensorflow model from cloud file store on start. To know which model to load, it looks up the latest reference in a psql db.</p>
  <p>Occasionally a retrain script runs using google cloud functions. This stores a new model in cloud file store and a new reference in the psql db.</p>
  <p>Currently, in order to use this new model I would need to redeploy the cloud run instance so it grabs the new model on start. <strong>How can I automate using the newest model instead?</strong> Of course something elegant, robust, and scalable is ideal, but if something hacky/clunky but functional is much easier that would be preferred. This is a throw-away prototype but it needs to be available and usable.</p>
  <p>I have considered a few options but I'm not sure how possible either of them are:</p>
  <ol>
  <li>Create some sort of postgres trigger/notification that the cloud run server listens to. Guess this would require another thread. This ups complexity and I'm unsure how multiple threads works with Cloud Run.</li>
  <li>Similar, but use a http pub/sub. Make an endpoint on the server to re-lookup and get the latest model. Publish on retrainer finish.</li>
  <li>could deploy a new instance and remove the old one after the retrainer runs. Simple in some regards, but seems riskier and it might be hard to accomplish programmatically.</li>
  </ol>