<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

from polyaxon_client.base import PolyaxonClient
from polyaxon_client.exceptions import PolyaxonException
from polyaxon_schemas.experiment import ExperimentConfig
from polyaxon_schemas.project import ExperimentGroupConfig


class ExperimentGroupClient(PolyaxonClient):
    """Client to get experiments for a group from the server"""
    ENDPOINT = "/"

    def get_experiment_group(self, username, project_name, group_sequence):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence)
        try:
            response = self.get(request_url)
            return ExperimentGroupConfig.from_dict(response.json())
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while retrieving project')
            return None

    def list_experiments(self,
                         username,
                         project_name,
                         group_sequence,
                         query=None,
                         sort=None,
                         page=1):
        """Fetch list of experiments related to this experiment group."""
        request_url = self._build_url(self._get_http_url(), username, project_name, 'experiments')

        try:
            params = self.get_page(page=page)
            params['group'] = group_sequence
            if query:
                params['query'] = query
            if sort:
                params['sort'] = sort
            response = self.get(request_url, params=params)
            return self.prepare_list_results(response.json(), page, ExperimentConfig)
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while retrieving experiments')
            return []

    def update_experiment_group(self, username, project_name, group_sequence, patch_dict):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence)

        try:
            response = self.patch(request_url, json_data=patch_dict)
            return ExperimentGroupConfig.from_dict(response.json())
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while updating project')
            return None

    def delete_experiment_group(self, username, project_name, group_sequence):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence)
        try:
            response = self.delete(request_url)
            return response
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while deleting experiment group')
            return None

    def stop(self, username, project_name, group_sequence, pending=False):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence,
                                      'stop')
        json_data = None
        if pending is True:
            json_data = {'pending': pending}

        try:
            return self.post(request_url, json_data=json_data)
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while stopping experiments in group')
            return None

    def start_tensorboard(self, username, project_name, group_sequence, job_config=None):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence,
                                      'tensorboard',
                                      'start')

        try:
            job_config = {'config': job_config} if job_config else {}
            return self.post(request_url, json_data=job_config)
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while starting tensorboard')
            return None

    def stop_tensorboard(self, username, project_name, group_sequence):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence,
                                      'tensorboard',
                                      'stop')
        try:
            return self.post(request_url)
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while stopping tensorboard')
            return None
<commit_msg>Fix prospector<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

from polyaxon_client.base import PolyaxonClient
from polyaxon_client.exceptions import PolyaxonException
from polyaxon_schemas.experiment import ExperimentConfig
from polyaxon_schemas.project import ExperimentGroupConfig


class ExperimentGroupClient(PolyaxonClient):
    """Client to get experiments for a group from the server"""
    ENDPOINT = "/"

    def get_experiment_group(self, username, project_name, group_sequence):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence)
        try:
            response = self.get(request_url)
            return ExperimentGroupConfig.from_dict(response.json())
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while retrieving project')
            return None

    def list_experiments(self,
                         username,
                         project_name,
                         group_sequence,
                         query=None,
                         sort=None,
                         page=1):
        """Fetch list of experiments related to this experiment group."""
        request_url = self._build_url(self._get_http_url(), username, project_name, 'experiments')

        try:
            params = self.get_page(page=page)
            params['group'] = group_sequence
            if query:
                params['query'] = query
            if sort:
                params['sort'] = sort
            response = self.get(request_url, params=params)
            return self.prepare_list_results(response.json(), page, ExperimentConfig)
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while retrieving experiments')
            return []

    def update_experiment_group(self, username, project_name, group_sequence, patch_dict):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence)

        try:
            response = self.patch(request_url, json_data=patch_dict)
            return ExperimentGroupConfig.from_dict(response.json())
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while updating project')
            return None

    def delete_experiment_group(self, username, project_name, group_sequence):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence)
        try:
            response = self.delete(request_url)
            return response
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while deleting experiment group')
            return None

    def stop(self, username, project_name, group_sequence, pending=False):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence,
                                      'stop')
        json_data = None
        if pending is True:
            json_data = {'pending': pending}

        try:
            return self.post(request_url, json_data=json_data)
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while stopping experiments in group')
            return None

    def start_tensorboard(self, username, project_name, group_sequence, job_config=None):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence,
                                      'tensorboard',
                                      'start')

        try:
            job_config = {'config': job_config} if job_config else {}
            return self.post(request_url, json_data=job_config)
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while starting tensorboard')
            return None

    def stop_tensorboard(self, username, project_name, group_sequence):
        request_url = self._build_url(self._get_http_url(),
                                      username,
                                      project_name,
                                      'groups',
                                      group_sequence,
                                      'tensorboard',
                                      'stop')
        try:
            return self.post(request_url)
        except PolyaxonException as e:
            self.handle_exception(e=e, log_message='Error while stopping tensorboard')
            return None
{'fraction_non_alphanumeric': 0.0667906976744186, 'fraction_numerical': 0.00037209302325581393, 'mean_word_length': 1.39603298417651, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 58, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4920507', 'n_tokens_mistral': 2486, 'n_tokens_neox': 2339, 'n_words': 551}