class_docstr: QueryGenerator is a helper object to write filters for runs.
class_docstr_tok: ["QueryGenerator","is","a","helper","object","to","write","filters","for","runs","."]
code: def mongo_to_filter(self, filter):
      # Returns {"op": "OR", "filters": [{"op": "AND", "filters": []}]}
      if filter is None:
          return None  # this covers the case where self.filter_to_mongo returns None.
  
      group_op = None
      for key in filter.keys():
          # if self.MONGO_TO_GROUP_OP[key]:
          if key in self.MONGO_TO_GROUP_OP:
              group_op = key
              break
      if group_op is not None:
          return {
              "op": self.MONGO_TO_GROUP_OP[group_op],
              "filters": [
                  self.mongo_to_filter(f) for f in filter[group_op]
              ],
          }
      else:
          for k, v in filter.items():
              if isinstance(v, dict):
                  # TODO: do we always have one key in this case?
                  op = next(iter(v.keys()))
                  return {
                      "key": self.server_path_to_key(k),
                      "op": self.MONGO_TO_INDIVIDUAL_OP[op],
                      "value": v[op],
                  }
              else:
                  return {
                      "key": self.server_path_to_key(k),
                      "op": "=",
                      "value": v,
                  }
  
file_path: wandb/wandb/apis/public/query_generator.py
label_desc: Use image node_id 12 for calling the QueryGenerator obj's underlying member method code with example usage: obj.mongo_to_filter(filter) and returns: None, dict, dict, dict