<commit_before># Copyright (c) 2016, <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except 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 os.path
import shutil

import zoe_master.workspace.base
import zoe_master.config as config


class ZoeFSWorkspace(zoe_master.workspace.base.ZoeWorkspaceBase):
    def __init__(self):
        self.base_path = os.path.join(config.get_conf().workspace_base_path, config.get_conf().deployment_name)

    def create(self, user):
        path = os.path.join(self.base_path, user.name)
        os.makedirs(path, exist_ok=True)

    def destroy(self, user):
        path = os.path.join(self.base_path, user.name)
        shutil.rmtree(path)

    def exists(self, user):
        return os.path.exists(os.path.join(self.base_path, user.name))

    def get_path(self, user):
        return os.path.join(self.base_path, user.name)

    def can_be_attached(self):
        return True

    def get_mountpoint(self):
        return '/mnt/workspace'
<commit_msg>Print a warning instead of raising an exception when failing to remove a workspace<commit_after># Copyright (c) 2016, <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except 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 os.path
import shutil
import logging

import zoe_master.workspace.base
import zoe_master.config as config

log = logging.getLogger(__name__)


class ZoeFSWorkspace(zoe_master.workspace.base.ZoeWorkspaceBase):
    def __init__(self):
        self.base_path = os.path.join(config.get_conf().workspace_base_path, config.get_conf().deployment_name)

    def create(self, user):
        path = os.path.join(self.base_path, user.name)
        os.makedirs(path, exist_ok=True)

    def destroy(self, user):
        path = os.path.join(self.base_path, user.name)
        try:
            shutil.rmtree(path)
        except OSError:
            log.warning("Cannot remove workspace directory %s" % path)

    def exists(self, user):
        return os.path.exists(os.path.join(self.base_path, user.name))

    def get_path(self, user):
        return os.path.join(self.base_path, user.name)

    def can_be_attached(self):
        return True

    def get_mountpoint(self):
        return '/mnt/workspace'

{'fraction_non_alphanumeric': 0.09516180711310478, 'fraction_numerical': 0.00512656199935918, 'mean_word_length': 3.5377906976744184, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7131113', 'n_tokens_mistral': 954, 'n_tokens_neox': 932, 'n_words': 296}