Stefan Adelbert
11/25/2022, 4:04 AMcontext.instance.get_runs()
and then runs some checks on those jobs, so that should cover the last point above.
But it's not clear from the [documentation](https://docs.dagster.io/_apidocs/internals#instance) how I could programmatically get information about workspaces, jobs and schedules from the dagster instance.
I can get this information from the GraphQL API (https://docs.dagster.io/concepts/dagit/graphql#get-a-list-of-repositories), but I'd rather have a job collect this info and then "call home". Any advice on this would be very useful.Denis Maciel
11/25/2022, 12:48 PMStefan Adelbert
11/27/2022, 9:15 PMgql
(like the dagster GraphQL python client does).Denis Maciel
11/29/2022, 4:22 AMowen
11/29/2022, 4:21 PM{
repositoriesOrError {
... on RepositoryConnection {
nodes {
name
jobs {
name
schedules {
name
}
}
}
}
}
}
This will return data of the form:
"data": {
"repositoriesOrError": {
"nodes": [
{
"name": "hacker_news_repository",
"jobs": [
{
"name": "__ASSET_JOB_0",
"schedules": []
},
{
"name": "activity_analytics_job",
"schedules": []
},
{
"name": "core_job",
"schedules": [
{
"name": "core_job_schedule"
}
]
},
{
"name": "story_recommender_job",
"schedules": []
}
]
},
]
}
}
, a list containing one element per repository, and each repository element contains a list of jobs, and each job contains a list of schedules that it's associated with. you can add more fields to this returned object if desired (digging around in <dagit_url>/graphql is pretty useful)Stefan Adelbert
11/29/2022, 10:41 PMdagit
is called dagit
, so I should be able to find the GraphQL endpoint implicitly from a user code repo container, i.e. http://dagit:3000/graphql. At least this way I can avoid configuration by convention.
I have modified my thinking subtly in that I reckon I'll periodically retrieve a list of all jobs (as you've outlined above) - this will give me a periodic snapshot.
And then for runs, I'll set up run status sensor (https://docs.dagster.io/concepts/partitions-schedules-sensors/sensors#run-status-sensors) which will update the reporting database with relevant run info.