<commit_before>"""Experiment run logging manager.

:copyright: Copyright 2011 <NAME>, see AUTHORS for details.
:license: Apache License, Version 2.0, see LICENSE for details.
"""

# Standard Library
import datetime
import getpass
import json
import os
import shlex
import stat
import subprocess as sp
import sys

# Third party
import requests
import yaml

# Local
from payu.fsops import DEFAULT_CONFIG_FNAME
from payu.fsops import mkdir_p


# Compatibility
try:
    input = raw_input
except NameError:
    pass


class Runlog(object):

    def __init__(self, expt):

        # Disable user's global git rc file
        os.environ['GIT_CONFIG_NOGLOBAL'] = 'yes'

        self.expt = expt

        # Fetch and update the runlog config
        runlog_config = self.expt.config.get('runlog', {})
        if isinstance(runlog_config, bool):
            self.enabled = runlog_config
            runlog_config = {}
        else:
            assert isinstance(runlog_config, dict)
            print(runlog_config)
            self.enabled = runlog_config.pop('enable', True)
        self.config = runlog_config

        self.manifest = []
        self.create_manifest()

        self.payu_config_dir = os.path.join(os.path.expanduser('~'), '.payu')
        self.token_path = os.path.join(self.payu_config_dir, 'tokens.yaml')

    def create_manifest(self):

        config_path = os.path.join(self.expt.control_path,
                                   DEFAULT_CONFIG_FNAME)

        if os.path.isfile(config_path):
            self.manifest.append(config_path)

        for model in self.expt.models:
            config_files = model.config_files + model.optional_config_files

            self.manifest.extend(os.path.join(model.control_path, f)
                                 for f in config_files)

    def commit(self):
        f_null = open(os.devnull, 'w')

        # Check if a repository exists
        cmd = 'git rev-parse'<commit_msg>Removing a print debug<commit_after>"""Experiment run logging manager.

:copyright: Copyright 2011 <NAME>, see AUTHORS for details.
:license: Apache License, Version 2.0, see LICENSE for details.
"""

# Standard Library
import datetime
import getpass
import json
import os
import shlex
import stat
import subprocess as sp
import sys

# Third party
import requests
import yaml

# Local
from payu.fsops import DEFAULT_CONFIG_FNAME
from payu.fsops import mkdir_p


# Compatibility
try:
    input = raw_input
except NameError:
    pass


class Runlog(object):

    def __init__(self, expt):

        # Disable user's global git rc file
        os.environ['GIT_CONFIG_NOGLOBAL'] = 'yes'

        self.expt = expt

        # Fetch and update the runlog config
        runlog_config = self.expt.config.get('runlog', {})
        if isinstance(runlog_config, bool):
            self.enabled = runlog_config
            runlog_config = {}
        else:
            assert isinstance(runlog_config, dict)
            self.enabled = runlog_config.pop('enable', True)
        self.config = runlog_config

        self.manifest = []
        self.create_manifest()

        self.payu_config_dir = os.path.join(os.path.expanduser('~'), '.payu')
        self.token_path = os.path.join(self.payu_config_dir, 'tokens.yaml')

    def create_manifest(self):

        config_path = os.path.join(self.expt.control_path,
                                   DEFAULT_CONFIG_FNAME)

        if os.path.isfile(config_path):
            self.manifest.append(config_path)

        for model in self.expt.models:
            config_files = model.config_files + model.optional_config_files

            self.manifest.extend(os.path.join(model.control_path, f)
                                 for f in config_files)

    def commit(self):
        f_null = open(os.devnull, 'w')

        # Check if a repository exists
        cmd = 'git rev-parse'
{'fraction_non_alphanumeric': 0.08982346832814123, 'fraction_numerical': 0.003115264797507788, 'mean_word_length': 2.4309884238646484, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1493641', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1125, 'n_words': 289}