https://dagster.io/ logo
Title
y

Yevhen Samoilenko

09/20/2022, 3:24 PM
Hi there! What is a recommended way to automatically run a job after a successful user code location update? Maybe using a sensor or something like that.
o

owen

09/20/2022, 5:26 PM
hi @Yevhen Samoilenko! One option would be to fire off a graphql query like
query WorkspaceUpdateCheckQuery {
    workspaceOrError {
      __typename
      ... on Workspace {
        locationEntries {
          __typename
          id
          loadStatus
          updatedTimestamp
        }
      }
    }
  }
within a sensor. That will return a response of the form:
{
  "data": {
    "workspaceOrError": {
      "__typename": "Workspace",
      "locationEntries": [
        {
          "__typename": "WorkspaceLocationEntry",
          "id": "my-repo-location",
          "loadStatus": "LOADED",
          "updatedTimestamp": 1663689795.3320975
        }
      ]
    }
  }
}
inside the sensor you can keep a cursor to keep track of the last updated timestamp for each of your locations (if you have multiple), and fire off a request when this timestamp changes
d

daniel

09/20/2022, 5:28 PM
In addition to owen's excellent proposal, if you're doing the user code location update over CI/CD, you could also try kicking off the job over the dagster graphql api as part of the CI process
y

Yevhen Samoilenko

09/21/2022, 7:34 AM
Cool! Thanks a lot!