https://dagster.io/ logo
Title
v

Vlad Efanov

02/27/2022, 8:16 AM
Hello. I want to create a sensor that receives requests from a web service, runs job and returns response to the web service with job ID. How can I do this? I need a sensor that waits for an event, not fired every x seconds.
d

daniel

02/28/2022, 5:00 AM
Hi Vlad, Dagster doesn't provide a built-in server for this purpose - but if you set up your own server, you could use our graphql api to launch the run and return the job ID in the response
v

Vlad Efanov

02/28/2022, 6:40 AM
@daniel Thanks. How can I get a list of Dagster runs using GraphQL Python client? I don't see it here https://docs.dagster.io/concepts/dagit/graphql-client
d

David Farnan-Williams

02/28/2022, 7:32 AM
It was easy for us to just interact with dagit creating a run and see what graphql command it sent, and then later which command it used to watch a run, and which one it used to cancel a run. In our case to send a run we tested using: LaunchPipelineExecution
v

Vlad Efanov

02/28/2022, 7:43 AM
@David Farnan-WilliamsI don't understand. Explain, please
d

David Farnan-Williams

02/28/2022, 10:00 AM
They seem to be using the graphql API for the dagit web UI. So I found it easiest just to interact with the the Dagit web app and watch what it is sending. Not necessarily a supported route to go(?), but it was quick and direct for me to find the command I needed. For starters launch the graphql playground: https://docs.dagster.io/concepts/dagit/graphql#using-the-graphql-playground From there you can test the command out to make sure it works, and there is a graphql API Docs on the right side. We were struggling finding it directly in the graphql api docs, and so we just watched what dagit sent. Assuming you have a functioning dagster repository: Launch dagit: https://docs.dagster.io/concepts/dagit/dagit Navigate to Launch pad: https://docs.dagster.io/getting-started#running-the-job-in-dagit Launch browser developer tools in your browser of choice: Hit Ctrl+Shift+I https://developer.mozilla.org/en-US/docs/Tools https://developer.chrome.com/docs/devtools/open/ Navigate to the Network Tab in your dev tools: https://developer.chrome.com/docs/devtools/network/ Check the box for "preserve log" which will keep the network log from dropping when the browser navigates away. Then clear the Network tab so you don't have any distracting events in the list. Then on the web page click the "Launch Run" button. This will capture the proper graphql command from your browser to the dagster-graphql api with the proper LaunchPipelineExecution command all filled in the way you want. Select the first "graphql" request that popped up on the list. Then click the "Payload" tab. That is essentially the graphql you must send to launch your run. In another browser window you can then paste in the payload to make sure everything works. Rinse and repeat for cancel and run status requests.
🙏 1
v

Vlad Efanov

02/28/2022, 10:51 AM
Thank you for your answer. I see that operationName is "PipelineRunsRootQuery". The question can I use this in GraphQL Python Client and how? I don't see a method in DagsterGraphQLClient that does this. If I can't, I'll just use the GraphQL API
d

daniel

02/28/2022, 1:07 PM
If it's not on the graphql client you would need to sue the graphql api directly, yeah
z

Zach

02/28/2022, 4:52 PM
@David Farnan-Williams that was an awesome answer and a great idea for getting going with the graphql API - I'm just creeping on threads and saw that, saved that tidbit of knowledge in my bookmarks for later!