Example #1
0
    def get_active_lumi_runs_by_list(self, list_of_run_numbers):
        """
        Get list of runs with certification status and active lumi sections

        Example:
        >>> client = TrackerRunRegistryClient()
        >>> runs = client.get_active_lumi_runs_by_list(["321777"])
        >>> runs[0]["lumi_sections"]
        279
        """
        where_clause = build_list_where_clause(list_of_run_numbers,
                                               "r.run_number")
        return self.__get_dataset_runs_with_active_lumis(where_clause)
Example #2
0
    def get_lumi_sections_by_list(self, list_of_run_numbers):
        """
        Get list of lumisections for the given run number list

        Example:
        >>> client = TrackerRunRegistryClient()
        >>> lumis = client.get_lumi_sections_by_list(["323471"])
        >>> lumis[0]["lhcfill"]
        7217

        :param list_of_run_numbers:
        :return:
        """
        where_clause = build_list_where_clause(list_of_run_numbers,
                                               "r.rdr_run_number")
        return self.__get_dataset_lumis_runs(where_clause)
Example #3
0
 def get_grouped_fill_numbers_by_run_number(self, list_of_run_numbers):
     """
     Example:
     >>> client = TrackerRunRegistryClient()
     >>> client.get_grouped_fill_numbers_by_run_number([321171, 321179, 321181, 321182, 321185])
     [{'fill_number': 7048, 'run_number': [321171, 321179, 321181]}, {'fill_number': 7049, 'run_number': [321182, 321185]}]
     """
     where_clause = build_list_where_clause(list_of_run_numbers,
                                            "r.runnumber")
     query = ("select r.lhcfill, r.runnumber "
              "from runreg_tracker.runs r "
              "where {} "
              "order by r.runnumber".format(where_clause))
     response = self.execute_query(query).get("data", [])
     groups = groupby(response, itemgetter(0))
     items = [(key, [item[1] for item in value]) for key, value in groups]
     keys = ["fill_number", "run_number"]
     return list_to_dict(items, keys)
Example #4
0
    def get_runs_by_list(self, list_of_run_numbers):
        """
        Get list of run dictionaries from the Tracker workspace in the Run Registry

        Example:
        >>> client = TrackerRunRegistryClient()
        >>> runs = client.get_runs_by_list(["323423"])
        >>> runs[0]["state"]
        'COMPLETED'

        :param list_of_run_numbers: list of run numbers
        :return: dictionary containing the queryset
        """
        if not list_of_run_numbers:
            return []

        where_clause = build_list_where_clause(list_of_run_numbers,
                                               "r.run_number")
        return self.__get_dataset_runs(where_clause)
Example #5
0
    def get_unique_fill_numbers_by_run_number(self, list_of_run_numbers):
        """
        Retrieve a list of unique fill numbers by the given run numbers

        Example:
        >>> client = TrackerRunRegistryClient()
        >>> client.get_unique_fill_numbers_by_run_number([321177, 321178, 321218, 323500])
        [7048, 7052]

        :param list_of_run_numbers:
        :return: list of dictionaries containing run number and corresponding fill number
        """

        where_clause = build_list_where_clause(list_of_run_numbers,
                                               "r.runnumber")
        query = ("select r.lhcfill "
                 "from runreg_tracker.runs r "
                 "where {} "
                 "order by r.runnumber".format(where_clause))
        runs = self.execute_query(query).get("data", [])
        return sorted({run[0] for run in runs if run[0] is not None})
Example #6
0
    def get_fill_number_by_run_number(self, list_of_run_numbers):
        """
        Retrieve a list of fill numbers by the given run numbers

        Example:
        >>> client = TrackerRunRegistryClient()
        >>> client.get_fill_number_by_run_number([321177, 321178, 321218])
        [{'run_number': 321177, 'fill_number': 7048}, {'run_number': 321178, 'fill_number': 7048}, {'run_number': 321218, 'fill_number': 7052}]

        :param list_of_run_numbers:
        :return: list of dictionaries containing run number and corresponding fill number
        """
        where_clause = build_list_where_clause(list_of_run_numbers,
                                               "r.runnumber")
        query = ("select r.runnumber, r.lhcfill "
                 "from runreg_tracker.runs r "
                 "where {} "
                 "order by r.runnumber".format(where_clause))
        items = self.execute_query(query).get("data", [])
        keys = ["run_number", "fill_number"]
        return list_to_dict(items, keys)
Example #7
0
    def get_run_numbers_by_fill_number(self, list_of_fill_numbers):
        """
        Retrieve a list of run numbers by the given fill numbers

        Example:
        >>> client = TrackerRunRegistryClient()
        >>> client.get_run_numbers_by_fill_number([7048, 7049])
        [{'fill_number': 7048, 'run_number': [321171, 321174, 321175, 321177, 321178, 321179, 321181]}, {'fill_number': 7049, 'run_number': [321182, 321185, 321189]}]

        :param list_of_fill_numbers:
        :return: list of dictionaries containing fill number and corresponding
        list of run numbers
        """
        where_clause = build_list_where_clause(list_of_fill_numbers,
                                               "r.lhcfill")
        query = ("select r.lhcfill, r.runnumber "
                 "from runreg_tracker.runs r "
                 "where {} "
                 "order by r.runnumber".format(where_clause))
        response = self.execute_query(query).get("data", [])
        groups = groupby(response, itemgetter(0))
        items = [(key, [item[1] for item in value]) for key, value in groups]
        keys = ["fill_number", "run_number"]
        return list_to_dict(items, keys)