Uh oh!
There was an error while loading. Please reload this page.
Adds DASH and PORT env vars - #1134
Conversation
alexcjohnson
commented
Feb 27, 2020
Alright, after way too much discussion with @josegonzalez and @rpkyle I'm on board with this change. Looks like you just have to adjust the usage re the test failure: And let's give it some helpful behavior if you fail to provide an int or a string that can be coerced to an int. Then we just need a CHANGELOG entry for the new options and I think this will be ready to 💃 |
OwenMatsuda
commented
Mar 2, 2020
@alexcjohnson What kind of helpful behavior do you think? Should it just default to the |
alexcjohnson
commented
Mar 3, 2020
Throw an error like |
846f445 to
da3f4ffCompareOwenMatsuda
commented
Mar 3, 2020
I think this is ready for review. My only potential concern is that for port, when the user inputs it as a parameter within |
| :param port: Port used to serve the application | ||
| env: ``PORT`` | ||
| :type port: int |
There was a problem hiding this comment.
Just mark port here as either an int or a string containing an int, and we should be covered re: data types. Your coercion and try/except below looks great!
Can you please add a couple of tests of the failure cases, and maybe one of setting an integer string port and verifying that an app shows up there? These can probably all go in https://github.com/plotly/dash/blob/dev/tests/unit/test_configs.py
The failures can just be something like:
app=Dash()
app.layout=html.Div()
withpytest.raises(...) asexcinfo:
app.run_server(port="garbage")
assertexcinfo.value== ...And the pass case can be something like:
app=Dash()
app.layout=html.Div("hi", id="out")
dash_duo.run_server(app, port="12345")
assertdash_duo.server_url=="https://127.0.0.1:12345"dash_duo.wait_for_text_to_equal("out", "hi")OwenMatsuda
commented
Mar 4, 2020
I'm trying to use pytest's monkeypatch to mock env vars, but I'm running into a bug: pytest-dev/pytest#6858 |
alexcjohnson
commented
Mar 4, 2020
There's a fixture |
OwenMatsuda
commented
Mar 4, 2020
I saw that, but that would mean adding the env vars env=load_dash_env_vars().get('DASH_{}'.format(name.upper()))
ifenvisNone:
returndefaultUnless we wanted to add another function specific to Along those same lines, I was wondering what the "parity" with Dash for Python was since the |
This PR adds the ability to set a DASH_HOST environment variable to change the host value when running the server.