-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds DASH and PORT env vars #1134
Conversation
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 💃 |
@alexcjohnson What kind of helpful behavior do you think? Should it just default to the |
Throw an error like |
846f445
to
da3f4ff
Compare
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()
with pytest.raises(...) as excinfo:
app.run_server(port="garbage")
assert excinfo.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")
assert dash_duo.server_url == "https://127.0.0.1:12345"
dash_duo.wait_for_text_to_equal("out", "hi")
I'm trying to use pytest's monkeypatch to mock env vars, but I'm running into a bug: pytest-dev/pytest#6858 |
There's a fixture |
I saw that, but that would mean adding the env vars env = load_dash_env_vars().get('DASH_{}'.format(name.upper()))
if env is None:
return default Unless 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 |
7774af1
to
37e66e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful. 💃
37e66e6
to
5f72204
Compare
This PR adds the ability to set a DASH_HOST environment variable to change the host value when running the server.