code: def upsert_sweep(self, config):
          
          mutation = gql('''
          mutation UpsertSweep(
              $config: String,
              $description: String,
              $entityName: String!,
              $projectName: String!
          ) {
              upsertSweep(input: {
                  config: $config,
                  description: $description,
                  entityName: $entityName,
                  projectName: $projectName
              }) {
                  sweep {
                      name
                  }
              }
          }
          ''')
  
          # don't retry on validation errors
          # TODO(jhr): generalize error handling routines
          def no_retry_400_or_404(e):
              if not isinstance(e, requests.HTTPError):
                  return True
              if e.response.status_code != 400 and e.response.status_code != 404:
                  return True
              body = json.loads(e.response.content)
              raise UsageError(body['errors'][0]['message'])
  
          response = self.gql(mutation, variable_values={
              'config': yaml.dump(config),
              'description': config.get("description"),
              'entityName': self.settings("entity"),
              'projectName': self.settings("project")},
              check_retry_fn=no_retry_400_or_404)
          return response['upsertSweep']['sweep']['name']
docs: Upsert a sweep object.
  
          Args:
              config (str): sweep config (will be converted to yaml)