Can I specify a schedule in dagster which is only ...
# ask-community
g
Can I specify a schedule in dagster which is only ever executed once? My goal is to have all the jobs start automatically once dagit is launched. Some jobs do not require updates, but must be executed once. Can I somehow trigger these jobs without a schedule automatically or run them all once somehow?
s
You can trigger an execution in Dagit, or through a GraphQL query. I think the way I would think about handling this is to just trigger them through a script.
g
is there a quick query to find all jobs which have no schedule attached?
or would I need to i.e. make one giant job (with some additional metadata perhaps) which would give me a way to trigger all assets without a schedule at once
s
hmm, not sure. another approach you might be able to take is to have a sensor that queries all jobs, and launches every one that it finds. if you pass in the job name as a unique run key, it will only ever try to launch the job once. then, the scheduled jobs would also run on their schedule. is that more what you're looking for?
g
hm that could be good enough
though I would prefer to not start the jobs which do have an associated schedule
s
it's possible you could write a graphql query that fetches all jobs, but filters out those that have any schedules associated with them, and use this for the sensor 🤔
g
hm this sounds quite reasonable.
are you aware of any similar example?
s
im not great at graphql, but maybe you can add another parameter here, or make a query for schedules and a query for jobs, then diff them: https://docs.dagster.io/concepts/dagit/graphql#get-a-list-of-jobs-within-a-repository
g
hm me neither.
perhaps someone of the dagster people could phrase a simple example?
the link you shared is an error 401 ...
s
oi facepalm , that was a run from our cluster. updated the link
o
I think the graphql solution makes a ton of sense, and getting both the jobs and the schedules and taking a diff also makes sense to me. If you want to get a response containing all the required info, that would look like
Copy code
query JobsQuery(
  $repositoryLocationName: String!
  $repositoryName: String!
) {
  repositoryOrError(
    repositorySelector: {
      repositoryLocationName: $repositoryLocationName
      repositoryName: $repositoryName
    }
  ) {
    ... on Repository {
      jobs {
        name
      }
      schedules {
        pipelineName
      }
    }
  }
}
🎉 2