https://dagster.io/ logo
#ask-community
Title
# ask-community
g

geoHeil

06/02/2022, 12:05 PM
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

Stephen Bailey

06/02/2022, 1:10 PM
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

geoHeil

06/02/2022, 1:26 PM
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

Stephen Bailey

06/02/2022, 2:10 PM
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

geoHeil

06/02/2022, 2:19 PM
hm that could be good enough
though I would prefer to not start the jobs which do have an associated schedule
s

Stephen Bailey

06/02/2022, 2:22 PM
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

geoHeil

06/02/2022, 2:27 PM
hm this sounds quite reasonable.
are you aware of any similar example?
s

Stephen Bailey

06/02/2022, 2:30 PM
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

geoHeil

06/02/2022, 2:54 PM
hm me neither.
perhaps someone of the dagster people could phrase a simple example?
the link you shared is an error 401 ...
s

Stephen Bailey

06/02/2022, 2:57 PM
oi facepalm , that was a run from our cluster. updated the link
o

owen

06/02/2022, 8:39 PM
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