<commit_before># Copyright (c) Two Sigma Open Source, LLC
#
# Licensed under the Apache license, Version 2.0 (the "License");
# you may not use this file ecept in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json

from copy import deepcopy
from datetime import datetime, timedelta
from enum import Enum
from uuid import UUID
from typing import Dict, List, Optional, Set

from .containers import AbstractContainer
from .instance import Executor, Instance
from .util import (
    clamped_ms_to_timedelta,
    unix_ms_to_datetime,
    datetime_to_unix_ms
)


class Status(Enum):
    """
    The curent status of a job.
    """
    WAITING = 'WAITING'
    """The job is currently waiting to begin."""
    RUNNING = 'RUNNING'
    """The job is currently running."""
    COMPLETED = 'COMPLETED'
    """The job has finished running."""

    def __str__(self):
        return self.value

    def __repr__(self):
        return f'Status.{self.value}'

    @staticmethod
    def from_string(name: str) -> 'Status':
        """Parse a ``Status`` from a case-invariant string representation."""
        return _JOB_STATUS_LOOKUP[name.lower()]


_JOB_STATUS_LOOKUP = {
    'waiting': Status.WAITING,
    'running': Status.RUNNING,
    'completed': Status.COMPLETED
}


class State(Enum):
    """The current status of a job.

    Indicates whether a job is currently running, has finished and succeeded,
    or has finished and failed.
    """
    WAITING = 'WAITING'
    """The job has not finished yet."""
    RUNNING = 'RUNNING'
    """The job is currently running."""
    SUCCESS = 'SUCCESS'
    """The job has finished and succeeded."""
    FAILED = 'FAILED'
    """The job has finished and failed."""

    def __str__(self):
        return self.value

    def __repr__(self):
        return f'State.{self.value}'

    @staticmethod
    def from_string(name: str) -> 'State':
        """Parse a ``State`` from a case-invariant string representation."""
        return _JOB_STATE_LOOKUP[name.lower()]


_JOB_STATE_LOOKUP = {
    'waiting': State.WAITING,
    'success': State.SUCCESS,
    'running': State.RUNNING,
    'failed': State.FAILED
}


class Application:
    """Application information associated with a job.

    :param name: Name of the application.
    :type name: str
    :param version: Application version.
    :type version: str
    """
    name: str
    version: str

    def __init__(self, name: str, version: str):
        self.name = name
        self.version = version

    def __str__(self):
        return json.dumps(self.to_dict, indent=4)

    def __repr__(self):
        return f'Application({self.name}, {self.version})'

    def to_dict(self) -> dict:
        return {
            'name': self.name,
            'version': self.version
        }

    @classmethod
    def from_dict(cls, d: dict) -> 'Application':
        """Parse an ``Application`` from its dict representation."""
        return cls(**d)

class Disk:
    """Disk information associated with a job.

    :param request: Disk request - guaranteed disk space for job.
    :type name: float
    :param limit: Disk limit - max disk space job can use.
    :type limit: float
    :param type: Disk type.
    :type type: str
    """
    request: float
    limit: float
    type: str

    def __init__(self, request: float, limit: float = None, type: str = None):
        self.request = request<commit_msg>Adds workload fields to application in python client (#1970)<commit_after># Copyright (c) Two Sigma Open Source, LLC
#
# Licensed under the Apache license, Version 2.0 (the "License");
# you may not use this file ecept in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json

from copy import deepcopy
from datetime import datetime, timedelta
from enum import Enum
from uuid import UUID
from typing import Dict, List, Optional, Set

from .containers import AbstractContainer
from .instance import Executor, Instance
from .util import (
    clamped_ms_to_timedelta,
    unix_ms_to_datetime,
    datetime_to_unix_ms
)


class Status(Enum):
    """
    The curent status of a job.
    """
    WAITING = 'WAITING'
    """The job is currently waiting to begin."""
    RUNNING = 'RUNNING'
    """The job is currently running."""
    COMPLETED = 'COMPLETED'
    """The job has finished running."""

    def __str__(self):
        return self.value

    def __repr__(self):
        return f'Status.{self.value}'

    @staticmethod
    def from_string(name: str) -> 'Status':
        """Parse a ``Status`` from a case-invariant string representation."""
        return _JOB_STATUS_LOOKUP[name.lower()]


_JOB_STATUS_LOOKUP = {
    'waiting': Status.WAITING,
    'running': Status.RUNNING,
    'completed': Status.COMPLETED
}


class State(Enum):
    """The current status of a job.

    Indicates whether a job is currently running, has finished and succeeded,
    or has finished and failed.
    """
    WAITING = 'WAITING'
    """The job has not finished yet."""
    RUNNING = 'RUNNING'
    """The job is currently running."""
    SUCCESS = 'SUCCESS'
    """The job has finished and succeeded."""
    FAILED = 'FAILED'
    """The job has finished and failed."""

    def __str__(self):
        return self.value

    def __repr__(self):
        return f'State.{self.value}'

    @staticmethod
    def from_string(name: str) -> 'State':
        """Parse a ``State`` from a case-invariant string representation."""
        return _JOB_STATE_LOOKUP[name.lower()]


_JOB_STATE_LOOKUP = {
    'waiting': State.WAITING,
    'success': State.SUCCESS,
    'running': State.RUNNING,
    'failed': State.FAILED
}


class Application:
    """Application information associated with a job.

    :param name: Name of the application.
    :type name: str
    :param version: Application version.
    :type version: str
    """
    name: str
    version: str
    workload_class: str
    workload_id: str
    workload_details: str

    def __init__(self, name: str, version: str, **kwargs):
        self.name = name
        self.version = version
        self.workload_class = kwargs.get('workload-class', None)
        self.workload_id = kwargs.get('workload-id', None)
        self.workload_details = kwargs.get('workload-details', None)

    def __str__(self):
        return json.dumps(self.to_dict, indent=4)

    def __repr__(self):
        return f'Application({self.name}, {self.version}, {self.workload_class}, ' \
               f'{self.workload_id}, {self.workload_details}) '

    def to_dict(self) -> dict:
        return {
            'name': self.name,
            'version': self.version,
            'workload-class': self.workload_class,
            'workload-id': self.workload_id,
            'workload-details': self.workload_details
        }

    @classmethod
    def from_dict(cls, d: dict) -> 'Application':
        """Parse an ``Application`` from its dict representation."""
        return cls(**d)

class Disk:
    """Disk information associated with a job.

    :param request: Disk request - guaranteed disk space for job.
    :type name: float
    :param limit: Disk limit - max disk space job can use.
    :type limit: float
    :param type: Disk type.
    :type type: str
    """
    request: float
    limit: float
    type: str

    def __init__(self, request: float, limit: float = None, type: str = None):
        self.request = request
{'fraction_non_alphanumeric': 0.10713407134071341, 'fraction_numerical': 0.0017220172201722018, 'mean_word_length': 2.9204435872709738, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3500400', 'n_tokens_mistral': 2393, 'n_tokens_neox': 2353, 'n_words': 840}