fine-tuning-service / src /environment_variable_checker.py
fashxp's picture
license
8a35bc0
# -------------------------------------------------------------------
# Pimcore
#
# This source file is available under two different licenses:
# - GNU General Public License version 3 (GPLv3)
# - Pimcore Commercial License (PCL)
# Full copyright and license information is available in
# LICENSE.md which is distributed with this source code.
#
# @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
# @license http://www.pimcore.org/license GPLv3 and PCL
# -------------------------------------------------------------------
import os
from fastapi import HTTPException, status
class EnvironmentVariableChecker:
def validate_environment_variables(self):
variables = ['AUTHENTICATION_TOKEN', 'HUGGINGFACE_TOKEN', 'HUGGINGFACE_ORGANIZATION']
for variable in variables:
if os.getenv(variable) is None:
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"Environment variable {variable} not set, please set the {variable} environment variable",
)
def get_authentication_token(self):
return os.getenv('AUTHENTICATION_TOKEN')
def get_huggingface_token(self):
return os.getenv('HUGGINGFACE_TOKEN');
def get_huggingface_organization(self):
return os.getenv('HUGGINGFACE_ORGANIZATION');