Source code for schrodinger.application.phase.license
"""
Module for token checkouts in phase related backends.
NOTE: Tampering with licensing is a violation of the license agreement.
Copyright Schrodinger LLC, All Rights Reserved.
"""
import sys
from schrodinger.utils import license
from schrodinger.utils import log
# Logging
logger = log.get_output_logger(__file__)
CPU_SHAPE_SCREEN_TOKENS = 1
GPU_SHAPE_SCREEN_TOKENS = 8
SHAPE_SCREEN_LICENSE_NAME = license.SHAPE_SCREEN
[docs]def num_of_shape_screen_tokens(use_gpu=False):
return GPU_SHAPE_SCREEN_TOKENS if use_gpu else CPU_SHAPE_SCREEN_TOKENS
[docs]def checkout_shape_screen_tokens(using_gpu=False):
"""
Checks out the appropriate number of tokens for a shape screening job.
:param using_gpu: whether to checkout tokens for GPU usage or not
:type using_gpu: bool
:return: license token
:rtype: `schrodinger.utils.license.License`
"""
tokens = license.License(SHAPE_SCREEN_LICENSE_NAME,
num_of_shape_screen_tokens(using_gpu))
if not tokens.isValid():
logger.error("SHAPE_SCREEN license token is unavailable. Contact "
"help@schrodinger.com to request additional licenses.")
sys.exit(1)
return tokens