HomePhabricator

Allow Dagit to be mounted at a path via new `—path` CLI param

Authored by bengotow on Jul 4 2020, 2:05 AM.

Description

Allow Dagit to be mounted at a path via new —path CLI param

Summary:
This diff adds a new --path param that hosts dagit and the /graphql endpoint at a subpath. No requests assume the root path, and hitting the root redirects to the prefixed path (just in case the user has not mounted something else at the root of the domain). The path you choose is injected into the the React app via a meta tag in the HTML, and is used to do two things:

  • We give React Router the path prefix. This makes most of the app "just work" which is actually fairly surprising - <Link to="/bla"> goes to "/path/bla" and <Route path="/bla" /> handles "/path/bla".
  • We store the path prefix and manually append it when we have to build URLs from scratch, eg: for opening new windows / tabs. To make this less of a pain point, I consolidated code that handles the launch/relaunch responses (it was nearly identical) so there is only one place in the app we manually assemble a run URL.

Sidenote: create-react-app is designed to support building apps to run on a path (and automatically prefixes the paths to assets, javascript, css, etc.) but we can't use their out-of-the-box support because we need the path specified at runtime. My solution of using find/replace to "fix" the paths in the index.html file isn't super great but gets the job done... :-/

Dev workflow: Right now there's not a great way to test this when you're running the React app via make. To test this, you need to build the React app (yarn build-for-python) and then serve it with dagit. I would like to change this and use a subpath all the time during development because it'd enforce good hygiene / prevent us from breaking support for paths in the future by accident, but I haven't found a good way to do it yet.

Test Plan: Run dagit at a path!

Reviewers: alangenfeld, prha, schrockn

Reviewed By: alangenfeld

Differential Revision: https://dagster.phacility.com/D3760

Details

Committed
bengotowJul 7 2020, 6:51 PM
Reviewer
alangenfeld
Differential Revision
D3760: Allow Dagit to be mounted at a path via new `—path` CLI param
Parents
R1:cc7164ee918d: Rerun snapshot for snap_test_active_data
Branches
Unknown
Tags
Unknown