Steffenhir / GraXpert

GraXpert is an astronomical image processing program for extracting and removing gradients from the background of your astrophotos.
https://www.graxpert.com/
GNU General Public License v3.0
158 stars 16 forks source link

Long timeout for checking remote AI versions #163

Open rakrok opened 3 months ago

rakrok commented 3 months ago

Hello,

Last night it seems like there was an issue with minio.schmelly.de, which caused my command-line invocations of GraXpert to hang on connect and timeout after many minutes. I forget now how long it took between the retries, but I believe each retry was 5 minutes and there were several of them (IIRC 5). Since I was running this through the GraXpert PixInsight plugin, there is no way to abort the process (as compared to e.g. the command line). Also FYI this was a connection hang (not an RST), so the retries took forever.

It would be nice if we could reduce this timeout and number of retries to something smaller. I don't have an opinion other than 5 minutes and 5 retries seems excessive :-)

I think the way to fix this is to pass in an http_client to the Minio constructor and specify the timeout there. This is a copy/paste of the http_client that is constructed within Minio, except with shorter timeouts. In ai_model_handling.py it would look like this:

timeout = 30 # seconds
http_client = urllib3.PoolManager(
            timeout=Timeout(connect=timeout, read=timeout),
            maxsize=10,
            cert_reqs='CERT_REQUIRED',
            ca_certs=os.environ.get('SSL_CERT_FILE') or certifi.where(),
            retries=Retry(
                total=2,
                backoff_factor=0.2,
                status_forcelist=[500, 502, 503, 504]
            )
        )
client = Minio(endpoint, ro_access_key, ro_secret_key, http_client=http_client)

I haven't been able to test this as I'm unable to build & run GraXpert myself (the instructions seem out of date, e.g. the onnxruntime was moved from requirements.txt, and then there is a failure in opening the s3 secrets files).

Let me know if I can provide any additional info. Or if you can let me know how to build GraXpert I can test this and submit a merge request. Thanks!