<commit_before>from tmlib.workflow.args import Argument
from tmlib.workflow.args import BatchArguments
from tmlib.workflow.args import SubmissionArguments
from tmlib.workflow.args import ExtraArguments
from tmlib.workflow.registry import batch_args
from tmlib.workflow.registry import submission_args
from tmlib.workflow.registry import extra_args


@batch_args('jterator')
class JteratorBatchArguments(BatchArguments):

    plot = Argument(
        type=bool, default=False, flag='p', disabled=True,
        help='whether plotting should be activated'
    )


@submission_args('jterator')
class JteratorSubmissionArguments(SubmissionArguments):

    pass


def get_names_of_existing_pipelines(experiment):
    '''Gets names of all existing jterator pipelines for a given experiment.

    Parameters
    ----------
    experiment: tmlib.models.Experiment
        processed experiment

    Returns
    -------
    List[str]
        names of jterator pipelines
    '''
    import os
    from tmlib.workflow.jterator.project import list_projects
    return [
        os.path.basename(project)
        for project
        in list_projects(os.path.join(experiment.workflow_location, 'jterator'))
    ]


@extra_args('jterator')
class JteratorExtraArguments(ExtraArguments):

    pipeline = Argument(
        type=str, help='name of the pipeline that should be processed',
        required=True, flag='p', get_choices=get_names_of_existing_pipelines
    )<commit_msg>Fix bug in function that lists existing jterator projects<commit_after>from tmlib.workflow.args import Argument
from tmlib.workflow.args import BatchArguments
from tmlib.workflow.args import SubmissionArguments
from tmlib.workflow.args import ExtraArguments
from tmlib.workflow.registry import batch_args
from tmlib.workflow.registry import submission_args
from tmlib.workflow.registry import extra_args


@batch_args('jterator')
class JteratorBatchArguments(BatchArguments):

    plot = Argument(
        type=bool, default=False, flag='p', disabled=True,
        help='whether plotting should be activated'
    )


@submission_args('jterator')
class JteratorSubmissionArguments(SubmissionArguments):

    pass


def get_names_of_existing_pipelines(experiment):
    '''Gets names of all existing jterator pipelines for a given experiment.

    Parameters
    ----------
    experiment: tmlib.models.Experiment
        processed experiment

    Returns
    -------
    List[str]
        names of jterator pipelines
    '''
    import os
    from tmlib.workflow.jterator.project import list_projects
    directory = os.path.join(experiment.workflow_location, 'jterator')
    if not os.path.exists(directory):
        return []
    else:
        return [
            os.path.basename(project)
            for project in list_projects(directory)
        ]


@extra_args('jterator')
class JteratorExtraArguments(ExtraArguments):

    pipeline = Argument(
        type=str, help='name of the pipeline that should be processed',
        required=True, flag='p', get_choices=get_names_of_existing_pipelines
    )
{'fraction_non_alphanumeric': 0.08382257012393998, 'fraction_numerical': 0.0, 'mean_word_length': 3.6896024464831805, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7469026', 'n_tokens_mistral': 891, 'n_tokens_neox': 863, 'n_words': 215}