wy_qcos.common package

Submodules

wy_qcos.common.args_schema module

wy_qcos.common.args_schema.is_valid_url(url, schemes)

Check if url is valid.

参数:
  • url -- url to check

  • schemes -- url schemes

返回:

True if valid, False otherwise

wy_qcos.common.config module

class wy_qcos.common.config.Config

基类:object

Config class.

DAEMON = False
DEBUG = False
MAX_JOBS = 10000
MAX_QUEUED_JOBS = 1000
VENV_DIR = '/var/lib/qcos/venv'
ENABLE_VIRT = False
MAX_JOBS_PER_VIRTUAL_INSTANCE = 10
PASSWORD_SALT = ''
API_WORKERS = 8
API_SERVER_LISTEN_IP = ''
API_SERVER_LISTEN_PORT = 18400
REDIS_SERVER_IP = '127.0.0.1'
REDIS_SERVER_PORT = 6379
QCOS_DATABASE_CONNECTION_URL = 'fake'
API_LOG_FILE = '/var/log/qcos/qcos-api.log'
LOG_FORMAT = '%(asctime)s %(levelname)s %(filename)s:%(lineno)s %(message)s'
LOG_ROTATE_MAX_SIZE_MB = 10
LOG_ROTATE_BACKUP_COUNT = 10
LOG_ROTATE_COMPRESSION = True
USE_SSL = False
CERT_FILE = None
KEY_FILE = None
CACERT_FILE = None
DEVICE_LIST = []
PREFECT_SERVER_DATABASE_CONNECTION_URL = 'sqlite+aiosqlite:///var/qcos/db/prefect.db'
PREFECT_API_URL = 'http://127.0.0.1:4200/api'
PREFECT_WORKER_QUERY_SECONDS = 30
PREFECT_WORKER_PREFETCH_SECONDS = 1
PREFECT_WORKER_HEARTBEAT_SECONDS = 30
PREFECT_LOCAL_STORAGE_PATH = '/var/qcos/storage'
PREFECT_LOGGING_LEVEL = 'INFO'
VALID_SECTIONS = ['DEFAULT', 'VIRT', 'API_SERVER', 'REDIS', 'DATABASE', 'LOG', 'SSL', 'PREFECT', 'DEVICES']
classmethod load_config_file(config_file, extra_config=False)

Parse a config file.

参数:
  • config_file -- config file

  • extra_config -- is extra config (Default value = False)

classmethod load_driver_env_file(config_file)

Load and validate driver env configuration file.

参数:

config_file -- config file path

classmethod validate()
classmethod get_configs(mask_password=False)
classmethod get_extra_configs()

Get extra configs.

返回:

extra configs

classmethod get_driver_env_configs()

Get driver env configs.

返回:

driver env configs

classmethod show_info()

Show class variables.

wy_qcos.common.constant module

class wy_qcos.common.constant.Constant

基类:object

Constants.

PROGRAM_NAME = 'WuYue-QCOS'
PROGRAM_AUTHOR = 'CMSS'
PLATFORM_NAME = '五岳量子计算操作系统(QCOS)'
PLATFORM_VERSION = '五岳量子计算操作系统(QCOS) v1.1.0'
COPYRIGHT = '2024-2026 中移(苏州)软件技术有限公司'
API_VERSION_V1 = 'v1'
API_VERSION = 'v1'
DEFAULT_API_SERVER_LISTEN_IP = ''
DEFAULT_API_SERVER_LISTEN_PORT = 18400
DEFAULT_API_VERSION = 'v1'
DEFAULT_QCOS_SERVER_IP = '127.0.0.1'
DEFAULT_QCOS_SERVER_PORT = 18400
DEFAULT_REDIS_SERVER_IP = '127.0.0.1'
DEFAULT_REDIS_SERVER_PORT = 6379
DEVICE_RUNNING_INFO_REDIS_CHANNEL_SUFFIX = '/device_running_info'
DB_DIALECT_POSTGRESQL = 'postgresql'
DEFAULT_FERNET_KEY = 'qevBn4Ol_3bJ7t0IW7TmPCCZurqfw_QRa810U43o_m0='
ENCRYPTION_PREFIX = '++'
FLOW_LIMIT = 100000
PYTHON_BIN = 'python3'
PYPY_BIN = 'pypy'
CODE_TYPE_QASM = 'qasm'
CODE_TYPE_QASM2 = 'qasm2'
CODE_TYPE_QASM3 = 'qasm3'
CODE_TYPE_QUBO = 'qubo'
CODE_TYPES_ALL_QASM = ['qasm', 'qasm2', 'qasm3']
CODE_TYPES = ['qasm', 'qasm2', 'qasm3', 'qubo']
AGGREGATION_TYPE_INTERNAL = 'internal'
AGGREGATION_TYPE_EXTERNAL = 'external'
AGGREGATION_TYPE_NONE = 'None'
AGGREGATION_TYPES = ['None', 'internal', 'external']
FILE_TYPE_QASM = '.qasm'
FILE_TYPE_JSON = '.json'
FILE_TYPE_CSV = '.csv'
MIN_DESCRIPTION_LENGTH = 1
MAX_DESCRIPTION_LENGTH = 255
SINGLE_QUBIT_GATE_X = 'x'
SINGLE_QUBIT_GATE_Y = 'y'
SINGLE_QUBIT_GATE_Z = 'z'
SINGLE_QUBIT_GATE_H = 'h'
SINGLE_QUBIT_GATE_S = 's'
SINGLE_QUBIT_GATE_T = 't'
SINGLE_QUBIT_GATE_P = 'p'
SINGLE_QUBIT_GATE_U = 'u'
SINGLE_QUBIT_GATE_U_UPPERCASE = 'U'
SINGLE_QUBIT_GATE_R = 'r'
SINGLE_QUBIT_GATE_RX = 'rx'
SINGLE_QUBIT_GATE_RY = 'ry'
SINGLE_QUBIT_GATE_RZ = 'rz'
SINGLE_QUBIT_GATE_SX = 'sx'
SINGLE_QUBIT_GATE_SXDG = 'sxdg'
SINGLE_QUBIT_GATE_SDG = 'sdg'
SINGLE_QUBIT_GATE_TDG = 'tdg'
SINGLE_QUBIT_GATE_U1 = 'u1'
SINGLE_QUBIT_GATE_U2 = 'u2'
SINGLE_QUBIT_GATE_U3 = 'u3'
SINGLE_QUBIT_GATE_RESET = 'reset'
SINGLE_QUBIT_GATE_LIST = ['x', 'y', 'z', 'h', 's', 't', 'p', 'u', 'U', 'r', 'rx', 'ry', 'rz', 'sx', 'sxdg', 'sdg', 'tdg', 'u1', 'u2', 'u3']
TWO_QUBIT_GATE_CH = 'ch'
TWO_QUBIT_GATE_CRX = 'crx'
TWO_QUBIT_GATE_CRY = 'cry'
TWO_QUBIT_GATE_CRZ = 'crz'
TWO_QUBIT_GATE_CX = 'cx'
TWO_QUBIT_GATE_CX_UPPERCASE = 'CX'
TWO_QUBIT_GATE_CY = 'cy'
TWO_QUBIT_GATE_CZ = 'cz'
TWO_QUBIT_GATE_SWAP = 'swap'
TWO_QUBIT_GATE_ISWAP = 'iswap'
TWO_QUBIT_GATE_CU1 = 'cu1'
TWO_QUBIT_GATE_CP = 'cp'
TWO_QUBIT_GATE_CS = 'cs'
TWO_QUBIT_GATE_CSDG = 'csdg'
TWO_QUBIT_GATE_CU3 = 'cu3'
TWO_QUBIT_GATE_ECR = 'ecr'
TWO_QUBIT_GATE_DCX = 'dcx'
TWO_QUBIT_GATE_CSX = 'csx'
TWO_QUBIT_GATE_CU = 'cu'
TWO_QUBIT_GATE_RXX = 'rxx'
TWO_QUBIT_GATE_RYY = 'ryy'
TWO_QUBIT_GATE_RZZ = 'rzz'
TWO_QUBIT_GATE_RZX = 'rzx'
TWO_QUBIT_GATE_LIST = ['ch', 'crx', 'cry', 'crz', 'cx', 'CX', 'cy', 'cz', 'swap', 'iswap', 'cu1', 'cp', 'cs', 'csdg', 'cu3', 'ecr', 'dcx', 'csx', 'cu', 'rxx', 'ecr', 'rzz', 'dcx']
THREE_QUBIT_GATE_CCX = 'ccx'
THREE_QUBIT_GATE_CSWAP = 'cswap'
THREE_QUBIT_GATE_RCCX = 'rccx'
THREE_QUBIT_GATE_LIST = ['ccx', 'cswap', 'rccx']
FOUR_QUBIT_GATE_RC3X = 'rc3x'
FOUR_QUBIT_GATE_C3X = 'c3x'
FOUR_QUBIT_GATE_C3SQRTX = 'c3sqrtx'
FOUR_QUBIT_GATE_LIST = ['rc3x', 'c3x', 'c3sqrtx']
FIVE_QUBIT_GATE_C4X = 'c4x'
FIVE_QUBIT_GATE_LIST = ['c4x']
ALL_GATE_LIST = ['x', 'y', 'z', 'h', 's', 't', 'p', 'u', 'U', 'r', 'rx', 'ry', 'rz', 'sx', 'sxdg', 'sdg', 'tdg', 'u1', 'u2', 'u3', 'ch', 'crx', 'cry', 'crz', 'cx', 'CX', 'cy', 'cz', 'swap', 'iswap', 'cu1', 'cp', 'cs', 'csdg', 'cu3', 'ecr', 'dcx', 'csx', 'cu', 'rxx', 'ecr', 'rzz', 'dcx', 'ccx', 'cswap', 'rccx', 'rc3x', 'c3x', 'c3sqrtx', 'c4x']
ALL_GATES = 'all'
DRIVER_DUMMY = 'dummy'
DRIVERS = {}
DEVICE_DUMMY = 'dummy'
DEVICE_MONITOR_PREFIX = 'device_monitor_'
TRANSPILER_CMSS = 'cmss'
TRANSPILER_QISKIT = 'qiskit'
TRANSPILER_DUMMY = 'dummy'
TRANSPILER_CMSS_QUBO = 'cmss_qubo'
TRANSPILERS = {}
TECH_TYPE_NONE = 'none'
TECH_TYPE_NEUTRAL_ATOM = 'neutral_atom'
TECH_TYPE_ION_TRAP = 'ion_trap'
TECH_TYPE_SUPERCONDUCTING = 'superconducting'
TECH_TYPE_PHOTON = 'photon'
TECH_TYPE_NMR = 'nmr'
TECH_TYPE_GENERIC_SIMULATOR = 'generic_simulator'
TECH_TYPE_INFO = {'generic_simulator': {'alias_name': '通用量子模拟器'}, 'ion_trap': {'alias_name': '离子阱'}, 'neutral_atom': {'alias_name': '中性原子'}, 'nmr': {'alias_name': '核磁共振'}, 'none': {'alias_name': '无'}, 'photon': {'alias_name': '光量子'}, 'superconducting': {'alias_name': '超导'}}
JOB_TYPE_SAMPLING = 'sampling'
JOB_TYPE_ESTIMATION = 'estimation'
JOB_TYPES = ['sampling', 'estimation']
RESULTS_FETCH_MODE_SYNC = 'sync'
RESULTS_FETCH_MODE_ASYNC = 'async'
RESULTS_FETCH_ASYNC_RETRIES = 3
RESULTS_FETCH_ASYNC_TIMEOUT = 30
PROFILING_TYPE_ALL = 'all'
PROFILING_TYPE_CODE = 'code'
PROFILING_TYPE_SCHEDULING = 'scheduling'
PROFILING_TYPE_DRIVER_PARSE = 'driver:parse'
PROFILING_TYPE_DRIVER_TRANSPILE = 'driver:transpile'
PROFILING_TYPE_DRIVER_RUN = 'driver:run'
PROFILING_TYPES = ['all', 'code', 'scheduling', 'driver:parse', 'driver:transpile', 'driver:run']
PROFILING_INFO = {'all': {'alias_name': '使能所有性能评估类型'}, 'code': {'alias_name': '作业中单代码执行耗时'}, 'driver:parse': {'alias_name': '代码解析耗时'}, 'driver:run': {'alias_name': '后端运行耗时'}, 'driver:transpile': {'alias_name': '转译器耗时'}, 'scheduling': {'alias_name': '调度器耗时'}}
CALLBACK_TYPE_RESULTS = 'results'
CALLBACK_TYPES = ['results']
MAX_AGGREGATION_JOBS = 5
DEFAULT_JOB_PRIORITY = 5
MIN_JOB_PRIORITY = 1
MAX_JOB_PRIORITY = 10
MAX_JOB_WORKER = 1
DEFAULT_AGGREGATION_JOB_INTERVAL = 10
DEFAULT_JOB_POOL_TYPE = 'process'
DEFAULT_POOL_CONCURRENCY = 1
DEFAULT_JOB_TIMEOUT = 300
DEFAULT_JOB_INTERVAL = 5
DEFAULT_DEVICE_MONITOR_RETRIES = 1000
DEFAULT_DEVICE_MONITOR_RETRY_INTERVAL = 5
DEFAULT_DEVICE_MONITOR_INTERVAL = 5
JOB_STATUS_UNKNOWN = 'UNKNOWN'
JOB_STATUS_QUEUED = 'QUEUED'
JOB_STATUS_RUNNING = 'RUNNING'
JOB_STATUS_FAILED = 'FAILED'
JOB_STATUS_COMPLETED = 'COMPLETED'
JOB_STATUS_CANCELLING = 'CANCELLING'
JOB_STATUS_CANCELLED = 'CANCELLED'
JOB_STATUS_DELETED = 'DELETED'
JOB_STATUSES = ['UNKNOWN', 'QUEUED', 'RUNNING', 'FAILED', 'COMPLETED', 'CANCELLING', 'CANCELLED', 'DELETED']
PREFECT_STATE_RUNNING = 'RUNNING'
PREFECT_STATE_SCHEDULED = 'SCHEDULED'
PREFECT_STATE_PENDING = 'PENDING'
PREFECT_STATE_LATE = 'LATE'
PREFECT_STATE_FAILED = 'FAILED'
PREFECT_STATE_COMPLETED = 'COMPLETED'
PREFECT_STATE_CRASHED = 'CRASHED'
PREFECT_STATE_CANCELLING = 'CANCELLING'
PREFECT_STATE_CANCELLED = 'CANCELLED'
PREFECT_STATE_PAUSED = 'PAUSED'
PREFECT_CANCEL_REQUIRED_STATES = ['RUNNING']
PREFECT_WAIT_STATES = ['SCHEDULED', 'PENDING']
VID_TAGS_PREFIX = 'VIRTUAL_INSTANCE_ID'
PREFECT_JOB_LOG_FORMAT = '{time:YYYY-MM-DD HH:mm:ss} | {level} | {name} | {message}'
DEFAULT_SHOTS = 1
MIN_SHOTS = 1
MAX_SHOTS = 10240
DEFAULT_QUBITS = 1
MIN_QUBITS = 1
MAX_QUBITS = 1024
DEFAULT_OPTIMIZATION_LEVEL = 1
MIN_OPTIMIZATION_LEVEL = 0
MAX_OPTIMIZATION_LEVEL = 3
MAX_QUBO_BIT_WIDTH = 8
MAX_QUBO_QUBITS = 2000
MAX_CIRCUIT_CUT = 100
MAX_RERURSIVE_DEPTH = 100
COMPLETE_RECONSTRUCTION_THRESHOLD = 32
DD_MAX_MEMORY = 1024
class wy_qcos.common.constant.HttpHeaders

基类:object

DEFAULT_JSON_HEADERS = {'Accept': 'application/json', 'Content-Type': 'application/json'}
class wy_qcos.common.constant.HttpMethod

基类:object

HTTP methods.

GET = 'get'
POST = 'post'
PUT = 'put'
PATCH = 'patch'
DELETE = 'delete'
class wy_qcos.common.constant.HttpCode

基类:object

HTTP status codes.

SUCCESS_OK = 200
SUCCESS_CREATED = 201
SUCCESS_ACCEPTED = 202
SUCCESS_NO_CONTENT = 204
BAD_REQUEST_ERROR = 400
UNAUTHORIZED_ERROR = 401
FORBIDDEN_ERROR = 403
NOT_FOUND_ERROR = 404
TIMEOUT_ERROR = 408
CONFLICT_ERROR = 409
INTERNAL_SERVER_ERROR = 500
NOT_IMPLEMENTED_ERROR = 501
SERVICE_UNAVAILABLE_ERROR = 503

wy_qcos.common.errors module

exception wy_qcos.common.errors.BaseException(message)

基类:Exception

Base exception.

get_error_code()

Get error code.

返回:

error code

get_err_msgs()
exception wy_qcos.common.errors.GenericException(message)

基类:BaseException

Generic exception.

module_name = 'Generic'
error_code = -10
err_type = 'Error'
exception wy_qcos.common.errors.InvalidArguments(message)

基类:BaseException

Invalid arguments.

module_name = 'Generic'
error_code = -11
err_type = 'Invalid arguments'
exception wy_qcos.common.errors.NotFound(message)

基类:BaseException

Not Found.

module_name = 'Generic'
error_code = -12
err_type = 'Not Found'
exception wy_qcos.common.errors.WorkFlowError(message)

基类:BaseException

Work Flow Error.

module_name = 'Workflow'
error_code = -13
err_type = 'Error'
exception wy_qcos.common.errors.JobEngineDriverInitError(message)

基类:BaseException

Job Engine: Driver Init Error.

module_name = 'JobEngine'
error_code = -100
err_type = 'Driver Init Error'
exception wy_qcos.common.errors.JobEngineTranspilerInitError(message)

基类:BaseException

Job Engine: Transpiler Init Error.

module_name = 'JobEngine'
error_code = -101
err_type = 'Transpiler Init Error'
exception wy_qcos.common.errors.JobEngineParseError(message)

基类:BaseException

Job Engine: Parse Error.

module_name = 'JobEngine'
error_code = -102
err_type = 'Parse Error'
exception wy_qcos.common.errors.JobEngineTranspileError(message)

基类:BaseException

Job Engine: Transpile Error.

module_name = 'JobEngine'
error_code = -103
err_type = 'Transpile Error'
exception wy_qcos.common.errors.JobEngineDriverRunError(message)

基类:BaseException

Job Engine: Driver Run Error.

module_name = 'JobEngine'
error_code = -104
err_type = 'Driver Run Error'
exception wy_qcos.common.errors.JobEngineCheckWidthError(message)

基类:BaseException

Job Engine: Check QUBO Matrix Bit Width Error.

module_name = 'JobEngine'
error_code = -105
err_type = 'Check QUBO Matrix Bit Width Error'
exception wy_qcos.common.errors.JobEnginePrecisionTooHighError(message)

基类:BaseException

Job Engine: Precision is too high.

resulting in subqubo with too few bits for processing.

module_name = 'JobEngine'
error_code = -106
err_type = 'Precision is too high Error'
exception wy_qcos.common.errors.JobEngineQubitLimitExceededError(message)

基类:BaseException

Job Engine: Device Qubit Limit Exceeded Error.

module_name = 'JobEngine'
error_code = -107
err_type = 'Device Qubit Limit Exceeded Error'
exception wy_qcos.common.errors.JobEngineCheckMatrixError(message)

基类:BaseException

Job Engine: Check Matrix Error.

module_name = 'JobEngine'
error_code = -108
err_type = 'Check Matrix Error'
exception wy_qcos.common.errors.JobEngineCircuitCuttingError(message)

基类:BaseException

Job Engine: Circuit Cutting Error.

module_name = 'JobEngine'
error_code = -109
err_type = 'Circuit Cutting Error'
exception wy_qcos.common.errors.JobEngineReconProbError(message)

基类:BaseException

Job Engine: Reconstruct Probability Error.

module_name = 'JobEngine'
error_code = -110
err_type = 'Reconstruct Probability Error'
exception wy_qcos.common.errors.JobEngineCompileError(message)

基类:BaseException

Job Engine: Compile Error.

module_name = 'JobEngine'
error_code = -111
err_type = 'Compile Error'

wy_qcos.common.library module

class wy_qcos.common.library.Library

基类:object

Library.

static get_brief_description(description)
static update_dict(dictionary, new_kvs)

Update a dictionary.

参数:
  • dictionary -- dictionary to be updated

  • new_kvs -- new key/values

返回:

updated dictionary

static remove_duplicates(lst)

Remove duplicates elements from a list.

参数:

lst -- list

返回:

list

static kill_pid(pid_file, expected_process_name=None, allow_kill_self=False)

Kill existing process from pid file.

参数:
  • pid_file -- pid file path

  • expected_process_name -- expected process name in regular expression

  • allow_kill_self -- allow kill current process

static create_file(file_path, file_content, mkdir=False, mode=None)

Create file.

参数:
  • file_path -- file path

  • file_content -- file content

  • mkdir -- if make dir

  • mode -- file mode

返回:

success, error messages

static create_pid_file(file_path)

Crete pid file.

参数:

file_path -- file path

static create_temp_file(file_content, dir=None, dir_mode=None)

Create temp file.

参数:
  • file_content -- file content

  • dir -- directory to create temp file

  • dir_mode -- directory mode

返回:

temp_dir_prefix

static is_file(file_path)

Is file.

参数:

file_path -- file path

static rm_file(file_path)

Remove file.

参数:

file_path -- file path

返回:

True or False

static find_dirs(base_dir='/', pattern='*', recursive=False, excludes=[])

Find all dirs.

参数:
  • base_dir -- base dir to search (Default value = "/")

  • pattern -- match pattern (Default value = "*")

  • recursive -- recursive search (Default value = False)

  • excludes -- excluded patterns (Default value = [])

返回:

matched dir list

static find_files(base_dir, pattern='*', recursive=False, exclusives=None)

Find files under given dir.

参数:
  • base_dir -- base dir to search

  • pattern -- match pattern (Default value = "*")

  • recursive -- recursive search (Default value = False)

  • exclusives -- filename to exclude (Default value = None)

返回:

file list

static get_top_dir()
static mkdir(dir_name, mode=None)

Create dir.

参数:
  • dir_name -- dir name

  • mode -- dir mode

返回:

True or False

static mkdirs(dir, mode=None)

Create dirs.

参数:
  • dir -- dir name

  • mode -- dir mode

static rmdir(dir)

Remove dir.

参数:

dir -- dir name

返回:

success, error messages

static get_processes(regex_list)

Get processes.

参数:

regex_list -- regex list to match

static kill(process_list, force=False)

Kill processes.

参数:
  • process_list -- processes

  • force (bool) -- force to kill

返回:

pids that are killed successfully, pids that are failed to kill

static get_venv_dirs(venv_base_dir, default_venv_dir='default')

Get venv dirs.

参数:
  • venv_base_dir -- base directory to search for virtual environments

  • default_venv_dir -- default venv dir name

返回:

list of venv directory paths that contain activate file

返回类型:

list

static set_venv_path(venv_base_dir)

Set venv path.

参数:

venv_base_dir -- venv base dir

static set_driver_venv_path(driver_name, venv_base_dir)

Set driver venv path.

参数:
  • driver_name -- driver name

  • venv_base_dir -- venv base dir

返回:

original sys.path

static get_driver_venv(driver_name, venv_dir, add_default_env=True)

Get driver venv.

参数:
  • driver_name -- driver name

  • venv_dir -- venv dir

  • add_default_env -- if add default env

返回:

python_bin, python_path_env

static import_classes(pkg_dir, base_module_name='drivers', base_dir=None, base_class=None, excluded_class=None, venv_base_dir=None, venv_loader=None)

Import class from package dir.

参数:
  • pkg_dir -- package dir

  • base_module_name -- base module name (Default value = "drivers")

  • base_dir -- base dir (Default value = None)

  • base_class -- base class (Default value = None)

  • excluded_class -- excluded class (Default value = None)

  • venv_base_dir -- venv base dir

  • venv_loader -- venv loader

返回:

class dict, venv_dirs

static str_match(str, regex, ignore_case=False)

Match string with regex.

参数:
  • str -- string

  • regex -- regex pattern

  • ignore_case -- ignore case (Default value = False)

返回:

bool

static read_file(file_path, replace_pattern=None, customer_format=None)

Read text file.

参数:
  • file_path -- file path

  • replace_pattern -- replace pattern (Default value = None)

  • customer_format -- customer format (Default value = None)

返回:

file content

static read_csv_file(file_path)
static read_toml_file(file_path)

Read toml file.

参数:
  • file_path (str) -- toml file path

  • file_path -- str:

返回:

success, err_msg, toml dict

static create_toml(file_path, data)

Write dict to toml file.

参数:
  • file_path (str) -- file_path

  • data (dict) -- data to write

返回:

success, err_msg

static get_current_datetime()

Get current datetime.

返回:

datetime

static create_uuid(prefix=[])
static validate_values_enum(value, param_name, value_list, allow_none=False)

Validate values for enum.

参数:
  • value -- value

  • param_name -- param name

  • value_list -- valid value list

  • allow_none -- allow None value (Default value = False)

返回:

success of failed (bool), error message list

static validate_values_uuid(value, param_name)

Validate values for uuid.

参数:
  • value -- value

  • param_name -- param name

返回:

success of failed (bool), error message list

static validate_values_range(value, param_name, min_value=None, max_value=None)

Validate values for int range.

参数:
  • value -- value

  • param_name -- param name

  • min_value -- minimum value (Default value = None)

  • max_value -- maximum value (Default value = None)

返回:

success of failed (bool), error message list

static validate_values_length(value, param_name, min_value=None, max_value=None, allow_none=False)

Validate values for int range.

参数:
  • value -- value

  • param_name -- param name

  • min_value -- minimum value (Default value = None)

  • max_value -- maximum value (Default value = None)

  • allow_none -- allow None value (Default value = False)

返回:

success of failed (bool), error message list

static validate_values_list(value, param_name, value_type, allow_none=False)

Validate values for list.

参数:
  • value -- value

  • param_name -- param name

  • value_type -- data type of value

  • allow_none -- allow None value (Default value = False)

返回:

success of failed (bool), error message list

static validate_schema(value, schema_obj, allow_none=False, ignore_extra_keys=False)

Validate schema values.

参数:
  • value -- value to be validated

  • schema_obj -- schema obj

  • allow_none -- allow None value (Default value = False)

  • ignore_extra_keys -- ignore extra keys (Default value = False)

返回:

success of failed (bool), error message list

static validate_qubo_matrices(qubo_matrices)

Validate qubo matrices.

参数:

qubo_matrices -- qubo matrices

返回:

success of failed (bool), error message

static call_http_api(url, method, *, data=None, json=None, files=None, params=None, func_name=None, headers=None, auth=None, verify_ssl=False, retries=1, timeout=10, success_http_code=[200, 201], debug=False)

Call http api.

参数:
  • url -- api url

  • method -- http method

  • data -- data for http body (Default value = None)

  • json -- json data for http body (Default value = None)

  • files -- files for http body (Default value = None)

  • params -- params for http url (Default value = None)

  • func_name -- function name (Default value = None)

  • headers -- http headers (Default value = None)

  • auth -- http auth (Default value = None)

  • verify_ssl -- if verify ssl certificate (Default value = False)

  • retries -- times to retry if failed (Default value = 1)

  • timeout -- timeout in seconds (Default value = 10)

  • success_http_code -- success http status (Default value = 200)

  • debug -- enable or disable debug (Default value = False)

async static async_call_http_api(url, method, *, data=None, json=None, params=None, func_name=None, headers=None, auth=None, retries=1, timeout=10, success_http_code=[200, 201], debug=False)

Async call http api.

参数:
  • url -- api url

  • method -- http method

  • data -- data for http body

  • json -- json data for http body

  • params -- params for http url

  • func_name -- function name

  • headers -- http headers

  • auth -- http auth

  • retries -- times to retry if failed

  • timeout -- timeout in seconds

  • success_http_code -- success http status

  • debug -- enable or disable debug

static is_valid_url(url, schemes)

Check if url is valid.

参数:
  • url -- url to check

  • schemes -- url schemes

返回:

True if valid, False otherwise

static get_zip_content(zip_filepath)
static loop_with_timeout(condition_check, timeout, interval, *args, **kwargs)

Wait loop with timeout.

参数:
  • condition_check -- function to check condition

  • timeout -- timeout in seconds

  • interval -- interval in seconds

  • args -- arguments to function condition_check

  • kwargs -- keyword arguments to function condition_check

  • *args -- arguments to function condition_check

  • **kwargs -- keyword arguments to function condition_check

返回:

True if condition met, False otherwise

static get_nested_dict_value(dictionary, *keys, default=None)

Get nested dict value.

参数:
  • dictionary -- dictionary to get value from

  • keys -- keys to get

  • default -- default value

  • *keys -- keys to get

返回:

value from dictionary

static run_callbacks(data, callbacks)

Run callbacks for job.

参数:
  • data -- data to send

  • callbacks -- callbacks

async static async_run_callbacks(data, callbacks)

Async run callbacks for job.

参数:
  • data -- data to send

  • callbacks -- callbacks

static get_sorted_keys(sort_obj, sort_fields)

Get sorted keys from sort_obj.

参数:
  • sort_obj -- object to be sorted

  • sort_fields -- field list to be sort

返回:

sorted keys

static generate_binary_combinations(bit_length, total_count)

Generate binary-bits combinations.

Generate binary-bits combinations with given bit_length and assign random percentages

参数:
  • bit_length -- length of bits

  • total_count -- total number of bits

返回:

binary-bits combinations with random percentage

static md5_encrypt(text)

Encrypt text using md5.

参数:

text -- Text to be encrypted

返回:

Encrypted text

static encrypt_text(plaintext, encryption_prefix='++', fernet_key='')

Encrypt text.

参数:
  • plaintext -- plain text

  • encryption_prefix -- encryption prefix

  • fernet_key -- fernet key

返回:

success, error message, encrypted text

static decrypt_text(cipher_text, encryption_prefix='++', fernet_key='')

Decrypt text.

参数:
  • cipher_text -- ciphered text

  • encryption_prefix -- encryption prefix

  • fernet_key -- fernet key

返回:

success, error message, decrypted text

static mask_password(configs, password_replace='*' * 8, keys_to_match='^(?:_.*|.*(password|secret|hidden).*)$')

Mask password.

参数:
  • configs -- configs

  • password_replace -- password text to be replaced

  • keys_to_match -- keys to be matched (regular expression)

返回:

replaced configs

static encrypt_virtual_instance_id(device_names_list, uuid_str, salt='', encode=False)

Encrypt virtual instance id.

参数:
  • device_names_list -- device name

  • uuid_str -- uuid string

  • salt -- salt

  • encode -- whether to encode with utf-8

返回:

success, error message, virtual instance id

static decrypt_virtual_instance_id(virtual_instance_id, salt='', encode=False)

Decrypt virtual instance id.

参数:
  • virtual_instance_id -- virtual instance id

  • salt -- salt

  • encode -- whether to encode with utf-8

返回:

success, error message, device_names, instance_id

async static job_callback(flow, flow_run, state, results=None)

Job callback.

参数:
  • flow -- flow

  • flow_run -- flow run

  • state -- flow state

  • results -- flow results

wy_qcos.common.qcos_version module

class wy_qcos.common.qcos_version.QcosVersion

基类:object

QCOS Version.

VERSION = '1.1.0'

Module contents