Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Add server field to heroku deploy #631

Merged
merged 4 commits into from
Mar 14, 2023
Merged

Add server field to heroku deploy #631

merged 4 commits into from
Mar 14, 2023

Conversation

mike0sv
Copy link
Contributor

@mike0sv mike0sv commented Mar 8, 2023

closes #568

Heroku requires you to use PORT env to expose a port.
I changed HerokuServer to wrap arbitrary server (instead of subclassing FastAPIServer) and swap port for value from env. For that it needs to know which value is to swap, so I added port_field classvar to servers.

@mike0sv mike0sv requested a review from a team as a code owner March 8, 2023 11:56
@mike0sv mike0sv temporarily deployed to internal March 8, 2023 11:57 — with GitHub Actions Inactive
@aguschin
Copy link
Contributor

aguschin commented Mar 9, 2023

Deployed this and got:
image
traceback

File "/usr/local/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
File "/tmp/mlem_streamlit_script_r0upwkyt/script.py", line 20, in <module>
    model_form(get_client())
File "/usr/local/lib/python3.9/site-packages/mlem/contrib/streamlit/utils.py", line 115, in model_form
    methods = list(client.methods.keys())
File "/usr/local/lib/python3.9/site-packages/mlem/runtime/client.py", line 46, in methods
    return self.interface.__root__
File "/usr/local/lib/python3.9/site-packages/mlem/runtime/client.py", line 41, in interface
    self.interface_cache = self._interface_factory()
File "/usr/local/lib/python3.9/site-packages/mlem/runtime/client.py", line 183, in _interface_factory
    resp = requests.get(f"{self.base_url}/interface.json")
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 565, in send
    raise ConnectionError(e, request=request)

@aguschin
Copy link
Contributor

aguschin commented Mar 9, 2023

@mike0sv thanks for the PR! please TAL at this ^ and at CI failures 😃

@aguschin
Copy link
Contributor

2023-03-09T06:25:43.384593+00:00 app[web.1]: 2023-03-09 06:25:43.384 Registering DataFrameType to DataAnalyzer
2023-03-09T06:25:43.390941+00:00 app[web.1]: 2023-03-09 06:25:43,390 [DEBUG] mlem.core.hooks: Registering PandasImport to ImportAnalyzer
2023-03-09T06:25:43.390960+00:00 app[web.1]: 2023-03-09 06:25:43.390 Registering PandasImport to ImportAnalyzer
2023-03-09T06:25:43.391197+00:00 app[web.1]: 2023-03-09 06:25:43,391 [DEBUG] mlem.ext: Importing extension module mlem.contrib.callable
2023-03-09T06:25:43.391215+00:00 app[web.1]: 2023-03-09 06:25:43.391 Importing extension module mlem.contrib.callable
2023-03-09T06:25:43.393546+00:00 app[web.1]: 2023-03-09 06:25:43,393 [DEBUG] mlem.core.hooks: Registering CallableModelType to ModelAnalyzer
2023-03-09T06:25:43.393577+00:00 app[web.1]: 2023-03-09 06:25:43.393 Registering CallableModelType to ModelAnalyzer
2023-03-09T06:25:43.393847+00:00 app[web.1]: 2023-03-09 06:25:43,393 [DEBUG] mlem.ext: Importing extension module mlem.contrib.github
2023-03-09T06:25:43.393866+00:00 app[web.1]: 2023-03-09 06:25:43.393 Importing extension module mlem.contrib.github
2023-03-09T06:25:43.395787+00:00 app[web.1]: 2023-03-09 06:25:43,395 [DEBUG] mlem.ext: Importing extension module mlem.contrib.gitlabfs
2023-03-09T06:25:43.395802+00:00 app[web.1]: 2023-03-09 06:25:43.395 Importing extension module mlem.contrib.gitlabfs
2023-03-09T06:25:43.410605+00:00 app[web.1]: 2023-03-09 06:25:43,410 [DEBUG] mlem.ext: Importing extension module mlem.contrib.bitbucketfs
2023-03-09T06:25:43.410654+00:00 app[web.1]: 2023-03-09 06:25:43.410 Importing extension module mlem.contrib.bitbucketfs
2023-03-09T06:25:43.413091+00:00 app[web.1]: 2023-03-09 06:25:43,412 [DEBUG] mlem.ext: Importing extension module mlem.contrib.pip
2023-03-09T06:25:43.413147+00:00 app[web.1]: 2023-03-09 06:25:43.412 Importing extension module mlem.contrib.pip
2023-03-09T06:25:43.413511+00:00 app[web.1]: 2023-03-09 06:25:43,413 [DEBUG] mlem.ext: Importing extension module mlem.contrib.requirements
2023-03-09T06:25:43.413532+00:00 app[web.1]: 2023-03-09 06:25:43.413 Importing extension module mlem.contrib.requirements
2023-03-09T06:25:43.415040+00:00 app[web.1]: 2023-03-09 06:25:43,414 [DEBUG] mlem.ext: Importing extension module mlem.contrib.venv
2023-03-09T06:25:43.415061+00:00 app[web.1]: 2023-03-09 06:25:43.414 Importing extension module mlem.contrib.venv
2023-03-09T06:25:43.666392+00:00 app[web.1]: 2023-03-09 06:25:43.663 Uncaught app exception
2023-03-09T06:25:43.666407+00:00 app[web.1]: Traceback (most recent call last):
2023-03-09T06:25:43.666408+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
2023-03-09T06:25:43.666408+00:00 app[web.1]: conn = connection.create_connection(
2023-03-09T06:25:43.666408+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection
2023-03-09T06:25:43.666409+00:00 app[web.1]: raise err
2023-03-09T06:25:43.666410+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection
2023-03-09T06:25:43.666410+00:00 app[web.1]: sock.connect(sa)
2023-03-09T06:25:43.666411+00:00 app[web.1]: ConnectionRefusedError: [Errno 111] Connection refused
2023-03-09T06:25:43.666411+00:00 app[web.1]:
2023-03-09T06:25:43.666412+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2023-03-09T06:25:43.666413+00:00 app[web.1]:
2023-03-09T06:25:43.666413+00:00 app[web.1]: Traceback (most recent call last):
2023-03-09T06:25:43.666413+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
2023-03-09T06:25:43.666413+00:00 app[web.1]: httplib_response = self._make_request(
2023-03-09T06:25:43.666414+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 398, in _make_request
2023-03-09T06:25:43.666414+00:00 app[web.1]: conn.request(method, url, **httplib_request_kw)
2023-03-09T06:25:43.666415+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request
2023-03-09T06:25:43.666415+00:00 app[web.1]: super(HTTPConnection, self).request(method, url, body=body, headers=headers)
2023-03-09T06:25:43.666415+00:00 app[web.1]: File "/usr/local/lib/python3.9/http/client.py", line 1253, in request
2023-03-09T06:25:43.666415+00:00 app[web.1]: self._send_request(method, url, body, headers, encode_chunked)
2023-03-09T06:25:43.666416+00:00 app[web.1]: File "/usr/local/lib/python3.9/http/client.py", line 1299, in _send_request
2023-03-09T06:25:43.666416+00:00 app[web.1]: self.endheaders(body, encode_chunked=encode_chunked)
2023-03-09T06:25:43.666416+00:00 app[web.1]: File "/usr/local/lib/python3.9/http/client.py", line 1248, in endheaders
2023-03-09T06:25:43.666417+00:00 app[web.1]: self._send_output(message_body, encode_chunked=encode_chunked)
2023-03-09T06:25:43.666417+00:00 app[web.1]: File "/usr/local/lib/python3.9/http/client.py", line 1008, in _send_output
2023-03-09T06:25:43.666417+00:00 app[web.1]: self.send(msg)
2023-03-09T06:25:43.666417+00:00 app[web.1]: File "/usr/local/lib/python3.9/http/client.py", line 948, in send
2023-03-09T06:25:43.666418+00:00 app[web.1]: self.connect()
2023-03-09T06:25:43.666418+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 205, in connect
2023-03-09T06:25:43.666418+00:00 app[web.1]: conn = self._new_conn()
2023-03-09T06:25:43.666419+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
2023-03-09T06:25:43.666419+00:00 app[web.1]: raise NewConnectionError(
2023-03-09T06:25:43.666421+00:00 app[web.1]: urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f6a2e8221c0>: Failed to establish a new connection: [Errno 111] Connection refused
2023-03-09T06:25:43.666422+00:00 app[web.1]:
2023-03-09T06:25:43.666422+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2023-03-09T06:25:43.666422+00:00 app[web.1]:
2023-03-09T06:25:43.666422+00:00 app[web.1]: Traceback (most recent call last):
2023-03-09T06:25:43.666422+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 489, in send
2023-03-09T06:25:43.666423+00:00 app[web.1]: resp = conn.urlopen(
2023-03-09T06:25:43.666423+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 787, in urlopen
2023-03-09T06:25:43.666423+00:00 app[web.1]: retries = retries.increment(
2023-03-09T06:25:43.666423+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment
2023-03-09T06:25:43.666424+00:00 app[web.1]: raise MaxRetryError(_pool, url, error or ResponseError(cause))
2023-03-09T06:25:43.666435+00:00 app[web.1]: urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=8081): Max retries exceeded with url: /interface.json (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6a2e8221c0>: Failed to establish a new connection: [Errno 111] Connection refused'))
2023-03-09T06:25:43.666435+00:00 app[web.1]:
2023-03-09T06:25:43.666435+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2023-03-09T06:25:43.666436+00:00 app[web.1]:
2023-03-09T06:25:43.666436+00:00 app[web.1]: Traceback (most recent call last):
2023-03-09T06:25:43.666440+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
2023-03-09T06:25:43.666441+00:00 app[web.1]: exec(code, module.__dict__)
2023-03-09T06:25:43.666441+00:00 app[web.1]: File "/tmp/mlem_streamlit_script_r0upwkyt/script.py", line 20, in <module>
2023-03-09T06:25:43.666441+00:00 app[web.1]: model_form(get_client())
2023-03-09T06:25:43.666442+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/mlem/contrib/streamlit/utils.py", line 115, in model_form
2023-03-09T06:25:43.666442+00:00 app[web.1]: methods = list(client.methods.keys())
2023-03-09T06:25:43.666442+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/mlem/runtime/client.py", line 46, in methods
2023-03-09T06:25:43.666443+00:00 app[web.1]: return self.interface.__root__
2023-03-09T06:25:43.666443+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/mlem/runtime/client.py", line 41, in interface
2023-03-09T06:25:43.666443+00:00 app[web.1]: self.interface_cache = self._interface_factory()
2023-03-09T06:25:43.666444+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/mlem/runtime/client.py", line 183, in _interface_factory
2023-03-09T06:25:43.666444+00:00 app[web.1]: resp = requests.get(f"{self.base_url}/interface.json")
2023-03-09T06:25:43.666444+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 73, in get
2023-03-09T06:25:43.666445+00:00 app[web.1]: return request("get", url, params=params, **kwargs)
2023-03-09T06:25:43.666445+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 59, in request
2023-03-09T06:25:43.666450+00:00 app[web.1]: return session.request(method=method, url=url, **kwargs)
2023-03-09T06:25:43.666450+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 587, in request
2023-03-09T06:25:43.666450+00:00 app[web.1]: resp = self.send(prep, **send_kwargs)
2023-03-09T06:25:43.666451+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 701, in send
2023-03-09T06:25:43.666451+00:00 app[web.1]: r = adapter.send(request, **kwargs)
2023-03-09T06:25:43.666451+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 565, in send
2023-03-09T06:25:43.666452+00:00 app[web.1]: raise ConnectionError(e, request=request)
2023-03-09T06:25:43.666452+00:00 app[web.1]: requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=8081): Max retries exceeded with url: /interface.json (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6a2e8221c0>: Failed to establish a new connection: [Errno 111] Connection refused'))
2023-03-09T06:25:43.908694+00:00 heroku[router]: at=info method=GET path="/static/media/SourceSansPro-Bold.12e6acd2589d00c9d0aa.ttf" host=lyrics2emoji.herokuapp.com request_id=de60eed4-2ad0-4758-a5f8-92587845dc1a fwd="104.28.193.251" dyno=web.1 connect=0ms service=40ms status=200 bytes=267806 protocol=https
2023-03-09T06:25:44.121782+00:00 heroku[router]: at=info method=GET path="/static/media/SourceSansPro-SemiBold.43cc81b496222dc9ce3c.ttf" host=lyrics2emoji.herokuapp.com request_id=dc39dba9-3ad1-487c-9c58-ab80409aa82b fwd="104.28.193.251" dyno=web.1 connect=0ms service=8ms status=200 bytes=268698 protocol=https
2023-03-09T06:25:44.123276+00:00 heroku[router]: at=info method=GET path="/static/media/SourceCodePro-Regular.70cc7ff27245e82ad414.ttf" host=lyrics2emoji.herokuapp.com request_id=fe4b3f30-7cbb-4c88-ac29-5248495c7487 fwd="104.28.193.251" dyno=web.1 connect=0ms service=7ms status=200 bytes=193158 protocol=https
2023-03-09T06:59:33.501948+00:00 heroku[web.1]: Idling
2023-03-09T06:59:33.510581+00:00 heroku[web.1]: State changed from up to down
2023-03-09T06:59:36.094466+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2023-03-09T06:59:36.142123+00:00 app[web.1]: Stopping...
2023-03-09T06:59:36.152816+00:00 heroku[router]: at=info method=GET path="/_stcore/stream" host=lyrics2emoji.herokuapp.com request_id=0badd4a1-7417-458b-b8b3-27ac2ccf2703 fwd="104.28.193.251" dyno=web.1 connect=0ms service=2033286ms status=101 bytes=333 protocol=https
2023-03-09T06:59:36.318435+00:00 heroku[web.1]: Process exited with status 143

@aguschin aguschin temporarily deployed to internal March 10, 2023 03:11 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

Patch coverage: 60.00% and project coverage change: -0.08 ⚠️

Comparison is base (ffb2047) 86.09% compared to head (ef3f931) 86.02%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #631      +/-   ##
==========================================
- Coverage   86.09%   86.02%   -0.08%     
==========================================
  Files         107      107              
  Lines        9733     9764      +31     
==========================================
+ Hits         8380     8399      +19     
- Misses       1353     1365      +12     
Impacted Files Coverage Δ
mlem/runtime/server.py 89.02% <40.00%> (-1.55%) ⬇️
mlem/contrib/heroku/server.py 60.00% <50.00%> (-15.00%) ⬇️
mlem/contrib/streamlit/server.py 66.97% <75.00%> (-0.01%) ⬇️
mlem/contrib/fastapi.py 85.15% <100.00%> (+0.11%) ⬆️
mlem/contrib/heroku/build.py 61.29% <100.00%> (+3.22%) ⬆️
mlem/contrib/heroku/meta.py 58.62% <100.00%> (+1.99%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mike0sv mike0sv temporarily deployed to internal March 13, 2023 21:19 — with GitHub Actions Inactive
@aguschin
Copy link
Contributor

Checked, works! Thanks @mike0sv! 🚀

@aguschin aguschin merged commit 3bc673e into main Mar 14, 2023
@aguschin aguschin deleted the feature/heroku-server branch March 14, 2023 08:46
@omesser omesser added deploy Related to model deployment serve Serving models and removed serve Serving models labels Mar 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
deploy Related to model deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deploy run heroku: --server option is missing
3 participants