wy_qcos.common package
Subpackages
- wy_qcos.common.cmss package
- Submodules
- wy_qcos.common.cmss.barrier module
- wy_qcos.common.cmss.base_operation module
- wy_qcos.common.cmss.circuit_instruction module
- wy_qcos.common.cmss.delay module
- wy_qcos.common.cmss.duration module
- wy_qcos.common.cmss.gate_operation module
- wy_qcos.common.cmss.measure module
- wy_qcos.common.cmss.move module
- wy_qcos.common.cmss.operation module
- wy_qcos.common.cmss.qasm_converter module
- wy_qcos.common.cmss.quantum_circuit module
- wy_qcos.common.cmss.register module
- wy_qcos.common.cmss.reset module
- wy_qcos.common.cmss.sync module
- Module contents
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
- pydantic model wy_qcos.common.config.DefaultSection
基类:
BaseModelDEFAULT section configuration.
Show JSON schema
{ "title": "DefaultSection", "description": "DEFAULT section configuration.", "type": "object", "properties": { "DEBUG": { "default": false, "description": "Debug mode flag", "title": "Debug", "type": "boolean" }, "MAX_JOBS": { "default": 10000, "description": "Maximum number of jobs (all status)", "minimum": 1, "title": "Max Jobs", "type": "integer" }, "MAX_QUEUED_JOBS": { "default": 1000, "description": "Maximum number of queued+running jobs", "minimum": 1, "title": "Max Queued Jobs", "type": "integer" }, "AUTH_MODE": { "default": "no", "description": "Authentication mode: 'no', 'jwt', or 'virtual_instance'", "enum": [ "no", "jwt", "virtual_instance" ], "title": "Auth Mode", "type": "string" }, "VENV_DIR": { "default": "/var/lib/qcos/venv", "description": "Default virtual environment base directory", "title": "Venv Dir", "type": "string" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field DEBUG: bool = False
Debug mode flag
- field MAX_JOBS: int = 10000
Maximum number of jobs (all status)
- Constraints:
ge = 1
- field MAX_QUEUED_JOBS: int = 1000
Maximum number of queued+running jobs
- Constraints:
ge = 1
- field AUTH_MODE: Literal['no', 'jwt', 'virtual_instance'] = 'no'
Authentication mode: 'no', 'jwt', or 'virtual_instance'
- field VENV_DIR: str = '/var/lib/qcos/venv'
Default virtual environment base directory
- pydantic model wy_qcos.common.config.APIServerSection
基类:
BaseModelAPI_SERVER section configuration.
Show JSON schema
{ "title": "APIServerSection", "description": "API_SERVER section configuration.", "type": "object", "properties": { "API_WORKERS": { "default": 8, "description": "Number of API workers (1-256)", "maximum": 256, "minimum": 1, "title": "Api Workers", "type": "integer" }, "API_SERVER_LISTEN_IP": { "default": "", "description": "API server listen IP ('' for all addresses)", "title": "Api Server Listen Ip", "type": "string" }, "API_SERVER_LISTEN_PORT": { "default": 18400, "description": "API server listen port (1024-65535)", "maximum": 65535, "minimum": 1024, "title": "Api Server Listen Port", "type": "integer" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field API_WORKERS: int = 8
Number of API workers (1-256)
- Constraints:
ge = 1
le = 256
- field API_SERVER_LISTEN_IP: str = ''
API server listen IP ('' for all addresses)
- field API_SERVER_LISTEN_PORT: int = 18400
API server listen port (1024-65535)
- Constraints:
ge = 1024
le = 65535
- pydantic model wy_qcos.common.config.MetricsServerSection
基类:
BaseModelMETRICS_SERVER section configuration.
Show JSON schema
{ "title": "MetricsServerSection", "description": "METRICS_SERVER section configuration.", "type": "object", "properties": { "METRICS_SERVER_LISTEN_IP": { "default": "", "description": "Metrics server listen IP ('' for all addresses)", "title": "Metrics Server Listen Ip", "type": "string" }, "METRICS_SERVER_LISTEN_PORT": { "default": 19400, "description": "Metrics server listen port (1024-65535)", "maximum": 65535, "minimum": 1024, "title": "Metrics Server Listen Port", "type": "integer" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field METRICS_SERVER_LISTEN_IP: str = ''
Metrics server listen IP ('' for all addresses)
- field METRICS_SERVER_LISTEN_PORT: int = 19400
Metrics server listen port (1024-65535)
- Constraints:
ge = 1024
le = 65535
- pydantic model wy_qcos.common.config.PrefectSection
基类:
BaseModelPREFECT section configuration.
Show JSON schema
{ "title": "PrefectSection", "description": "PREFECT section configuration.", "type": "object", "properties": { "PREFECT_API_URL": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": "http://127.0.0.1:4200/api", "description": "Prefect API URL", "title": "Prefect Api Url" }, "PREFECT_SERVER_DATABASE_CONNECTION_URL": { "db_connection_url": true, "default": "sqlite+aiosqlite:///var/qcos/db/prefect.db", "description": "Prefect database connection URL", "sensitive": true, "title": "Prefect Server Database Connection Url", "type": "string" }, "PREFECT_WORKER_QUERY_SECONDS": { "default": 30, "description": "Prefect worker query interval in seconds", "minimum": 1, "title": "Prefect Worker Query Seconds", "type": "integer" }, "PREFECT_WORKER_PREFETCH_SECONDS": { "default": 1, "description": "Prefect worker prefetch interval in seconds", "minimum": 1, "title": "Prefect Worker Prefetch Seconds", "type": "integer" }, "PREFECT_WORKER_HEARTBEAT_SECONDS": { "default": 30, "description": "Prefect worker heartbeat interval in seconds", "minimum": 1, "title": "Prefect Worker Heartbeat Seconds", "type": "integer" }, "PREFECT_LOCAL_STORAGE_PATH": { "default": "/var/qcos/storage", "description": "Prefect local storage path", "title": "Prefect Local Storage Path", "type": "string" }, "PREFECT_LOGGING_LEVEL": { "default": "INFO", "description": "Prefect logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)", "enum": [ "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL" ], "title": "Prefect Logging Level", "type": "string" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field PREFECT_API_URL: str | None = 'http://127.0.0.1:4200/api'
Prefect API URL
- field PREFECT_SERVER_DATABASE_CONNECTION_URL: str = 'sqlite+aiosqlite:///var/qcos/db/prefect.db'
Prefect database connection URL
- field PREFECT_WORKER_QUERY_SECONDS: int = 30
Prefect worker query interval in seconds
- Constraints:
ge = 1
- field PREFECT_WORKER_PREFETCH_SECONDS: int = 1
Prefect worker prefetch interval in seconds
- Constraints:
ge = 1
- field PREFECT_WORKER_HEARTBEAT_SECONDS: int = 30
Prefect worker heartbeat interval in seconds
- Constraints:
ge = 1
- field PREFECT_LOCAL_STORAGE_PATH: str = '/var/qcos/storage'
Prefect local storage path
- field PREFECT_LOGGING_LEVEL: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] = 'INFO'
Prefect logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
- pydantic model wy_qcos.common.config.RedisSection
基类:
BaseModelREDIS section configuration.
Show JSON schema
{ "title": "RedisSection", "description": "REDIS section configuration.", "type": "object", "properties": { "REDIS_SERVER_IP": { "default": "127.0.0.1", "description": "Redis server IP address", "title": "Redis Server Ip", "type": "string" }, "REDIS_SERVER_PORT": { "default": 6379, "description": "Redis server port (1024-65535)", "maximum": 65535, "minimum": 1024, "title": "Redis Server Port", "type": "integer" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field REDIS_SERVER_IP: str = '127.0.0.1'
Redis server IP address
- field REDIS_SERVER_PORT: int = 6379
Redis server port (1024-65535)
- Constraints:
ge = 1024
le = 65535
- pydantic model wy_qcos.common.config.DatabaseSection
基类:
BaseModelDATABASE section configuration.
Show JSON schema
{ "title": "DatabaseSection", "description": "DATABASE section configuration.", "type": "object", "properties": { "QCOS_DATABASE_CONNECTION_URL": { "db_connection_url": true, "default": "sqlite:////var/qcos/db/qcos.db?timeout=30&journal_mode=WAL", "description": "QCOS database connection URL (sqlite or postgresql)", "sensitive": true, "title": "Qcos Database Connection Url", "type": "string" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field QCOS_DATABASE_CONNECTION_URL: str = 'sqlite:////var/qcos/db/qcos.db?timeout=30&journal_mode=WAL'
QCOS database connection URL (sqlite or postgresql)
- validate_url()
Validate database URL supports only sqlite or postgresql.
- 返回类型:
None
- pydantic model wy_qcos.common.config.UsersSection
基类:
BaseModelUSERS section configuration.
Show JSON schema
{ "title": "UsersSection", "description": "USERS section configuration.", "type": "object", "properties": { "PASSWORD_EXPIRY_DAYS": { "default": 90, "description": "Password expiry days (0 = never expire)", "minimum": 0, "title": "Password Expiry Days", "type": "integer" }, "MAX_LOGIN_ATTEMPTS": { "default": 5, "description": "Maximum login attempts before account lockout", "minimum": 1, "title": "Max Login Attempts", "type": "integer" }, "MAX_LOGIN_LOGS": { "default": 10000, "description": "Maximum number of login logs to keep in database", "minimum": 100, "title": "Max Login Logs", "type": "integer" }, "LOCKOUT_DURATION_MINUTES": { "default": 30, "description": "Account lockout duration in minutes", "minimum": 1, "title": "Lockout Duration Minutes", "type": "integer" }, "ACCESS_CONTROL_MODEL_FILE": { "default": "/etc/qcos/roles/casbin_model.conf", "description": "Casbin access control model file path", "title": "Access Control Model File", "type": "string" }, "ACCESS_CONTROL_POLICY_FILE": { "default": "/etc/qcos/roles/policy.conf", "description": "Casbin access control policy file path", "title": "Access Control Policy File", "type": "string" }, "ADMIN_PASSWORD": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "Admin password (encrypted)", "sensitive": true, "title": "Admin Password" }, "JWT_AUTH_SECRET_KEY": { "default": "47pW_6k8A4iU1Z8-r8G2j4_xN9M5V3L7Q9p2X1Y4Z0A", "description": "JWT authentication secret key", "sensitive": true, "title": "Jwt Auth Secret Key", "type": "string" }, "JWT_AUTH_ALGORITHM": { "default": "HS256", "description": "JWT authentication algorithm (HS256, HS512, RS256, etc.)", "title": "Jwt Auth Algorithm", "type": "string" }, "ACCESS_TOKEN_EXPIRE_MINUTES": { "default": 30, "description": "Access token expiry time in minutes", "minimum": 1, "title": "Access Token Expire Minutes", "type": "integer" }, "REFRESH_TOKEN_EXPIRE_DAYS": { "default": 7, "description": "Refresh token expiry time in days", "minimum": 1, "title": "Refresh Token Expire Days", "type": "integer" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field PASSWORD_EXPIRY_DAYS: int = 90
Password expiry days (0 = never expire)
- Constraints:
ge = 0
- field MAX_LOGIN_ATTEMPTS: int = 5
Maximum login attempts before account lockout
- Constraints:
ge = 1
- field MAX_LOGIN_LOGS: int = 10000
Maximum number of login logs to keep in database
- Constraints:
ge = 100
- field LOCKOUT_DURATION_MINUTES: int = 30
Account lockout duration in minutes
- Constraints:
ge = 1
- field ACCESS_CONTROL_MODEL_FILE: str = '/etc/qcos/roles/casbin_model.conf'
Casbin access control model file path
- field ACCESS_CONTROL_POLICY_FILE: str = '/etc/qcos/roles/policy.conf'
Casbin access control policy file path
- field ADMIN_PASSWORD: str | None = None
Admin password (encrypted)
- field JWT_AUTH_SECRET_KEY: str = '47pW_6k8A4iU1Z8-r8G2j4_xN9M5V3L7Q9p2X1Y4Z0A'
JWT authentication secret key
- field JWT_AUTH_ALGORITHM: str = 'HS256'
JWT authentication algorithm (HS256, HS512, RS256, etc.)
- field ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
Access token expiry time in minutes
- Constraints:
ge = 1
- field REFRESH_TOKEN_EXPIRE_DAYS: int = 7
Refresh token expiry time in days
- Constraints:
ge = 1
- pydantic model wy_qcos.common.config.VirtSection
基类:
BaseModelVIRT section configuration.
Show JSON schema
{ "title": "VirtSection", "description": "VIRT section configuration.", "type": "object", "properties": { "MAX_JOBS_PER_VIRTUAL_INSTANCE": { "default": 10, "description": "Maximum jobs per virtual instance", "minimum": 1, "title": "Max Jobs Per Virtual Instance", "type": "integer" }, "PASSWORD_SALT": { "default": "123456", "description": "Salt for password/encryption", "sensitive": true, "title": "Password Salt", "type": "string" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field MAX_JOBS_PER_VIRTUAL_INSTANCE: int = 10
Maximum jobs per virtual instance
- Constraints:
ge = 1
- field PASSWORD_SALT: str = '123456'
Salt for password/encryption
- pydantic model wy_qcos.common.config.LogSection
基类:
BaseModelLOG section configuration.
Show JSON schema
{ "title": "LogSection", "description": "LOG section configuration.", "type": "object", "properties": { "API_LOG_FILE": { "default": "/var/log/qcos/qcos-api.log", "description": "API log file path", "title": "Api Log File", "type": "string" }, "LOG_FORMAT": { "default": "%(asctime)s %(levelname)s %(filename)s:%(lineno)s %(message)s", "description": "Log message format", "title": "Log Format", "type": "string" }, "LOG_ROTATE_MAX_SIZE_MB": { "default": 10, "description": "Log file max size in MB before rotation", "minimum": 1, "title": "Log Rotate Max Size Mb", "type": "integer" }, "LOG_ROTATE_BACKUP_COUNT": { "default": 10, "description": "Number of backup log files to keep", "minimum": 1, "title": "Log Rotate Backup Count", "type": "integer" }, "LOG_ROTATE_COMPRESSION": { "default": true, "description": "Enable log file compression", "title": "Log Rotate Compression", "type": "boolean" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field API_LOG_FILE: str = '/var/log/qcos/qcos-api.log'
API log file path
- field LOG_FORMAT: str = '%(asctime)s %(levelname)s %(filename)s:%(lineno)s %(message)s'
Log message format
- field LOG_ROTATE_MAX_SIZE_MB: int = 10
Log file max size in MB before rotation
- Constraints:
ge = 1
- field LOG_ROTATE_BACKUP_COUNT: int = 10
Number of backup log files to keep
- Constraints:
ge = 1
- field LOG_ROTATE_COMPRESSION: bool = True
Enable log file compression
- pydantic model wy_qcos.common.config.SSLSection
基类:
BaseModelSSL section configuration.
Show JSON schema
{ "title": "SSLSection", "description": "SSL section configuration.", "type": "object", "properties": { "USE_SSL": { "default": false, "description": "Enable HTTPS for API server", "title": "Use Ssl", "type": "boolean" }, "CERT_FILE": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "SSL certificate file path", "title": "Cert File" }, "KEY_FILE": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "SSL private key file path", "title": "Key File" }, "CACERT_FILE": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "SSL CA certificate file path (optional)", "title": "Cacert File" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field USE_SSL: bool = False
Enable HTTPS for API server
- field CERT_FILE: str | None = None
SSL certificate file path
- field KEY_FILE: str | None = None
SSL private key file path
- field CACERT_FILE: str | None = None
SSL CA certificate file path (optional)
- pydantic model wy_qcos.common.config.DevicesSection
基类:
BaseModelDEVICES section configuration.
Show JSON schema
{ "title": "DevicesSection", "description": "DEVICES section configuration.", "type": "object", "properties": { "DEVICE_LIST": { "description": "List of enabled quantum devices", "items": { "type": "string" }, "title": "Device List", "type": "array" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field DEVICE_LIST: list[str] [Optional]
List of enabled quantum devices
- pydantic model wy_qcos.common.config.ConfigModel
基类:
BaseModelComplete QCOS configuration model.
Show JSON schema
{ "title": "ConfigModel", "description": "Complete QCOS configuration model.", "type": "object", "properties": { "DEFAULT": { "$ref": "#/$defs/DefaultSection" }, "API_SERVER": { "$ref": "#/$defs/APIServerSection" }, "METRICS_SERVER": { "$ref": "#/$defs/MetricsServerSection" }, "PREFECT": { "$ref": "#/$defs/PrefectSection" }, "REDIS": { "$ref": "#/$defs/RedisSection" }, "DATABASE": { "$ref": "#/$defs/DatabaseSection" }, "USERS": { "$ref": "#/$defs/UsersSection" }, "VIRT": { "$ref": "#/$defs/VirtSection" }, "LOG": { "$ref": "#/$defs/LogSection" }, "SSL": { "$ref": "#/$defs/SSLSection" }, "DEVICES": { "$ref": "#/$defs/DevicesSection" } }, "$defs": { "APIServerSection": { "additionalProperties": false, "description": "API_SERVER section configuration.", "properties": { "API_WORKERS": { "default": 8, "description": "Number of API workers (1-256)", "maximum": 256, "minimum": 1, "title": "Api Workers", "type": "integer" }, "API_SERVER_LISTEN_IP": { "default": "", "description": "API server listen IP ('' for all addresses)", "title": "Api Server Listen Ip", "type": "string" }, "API_SERVER_LISTEN_PORT": { "default": 18400, "description": "API server listen port (1024-65535)", "maximum": 65535, "minimum": 1024, "title": "Api Server Listen Port", "type": "integer" } }, "title": "APIServerSection", "type": "object" }, "DatabaseSection": { "additionalProperties": false, "description": "DATABASE section configuration.", "properties": { "QCOS_DATABASE_CONNECTION_URL": { "db_connection_url": true, "default": "sqlite:////var/qcos/db/qcos.db?timeout=30&journal_mode=WAL", "description": "QCOS database connection URL (sqlite or postgresql)", "sensitive": true, "title": "Qcos Database Connection Url", "type": "string" } }, "title": "DatabaseSection", "type": "object" }, "DefaultSection": { "additionalProperties": false, "description": "DEFAULT section configuration.", "properties": { "DEBUG": { "default": false, "description": "Debug mode flag", "title": "Debug", "type": "boolean" }, "MAX_JOBS": { "default": 10000, "description": "Maximum number of jobs (all status)", "minimum": 1, "title": "Max Jobs", "type": "integer" }, "MAX_QUEUED_JOBS": { "default": 1000, "description": "Maximum number of queued+running jobs", "minimum": 1, "title": "Max Queued Jobs", "type": "integer" }, "AUTH_MODE": { "default": "no", "description": "Authentication mode: 'no', 'jwt', or 'virtual_instance'", "enum": [ "no", "jwt", "virtual_instance" ], "title": "Auth Mode", "type": "string" }, "VENV_DIR": { "default": "/var/lib/qcos/venv", "description": "Default virtual environment base directory", "title": "Venv Dir", "type": "string" } }, "title": "DefaultSection", "type": "object" }, "DevicesSection": { "additionalProperties": false, "description": "DEVICES section configuration.", "properties": { "DEVICE_LIST": { "description": "List of enabled quantum devices", "items": { "type": "string" }, "title": "Device List", "type": "array" } }, "title": "DevicesSection", "type": "object" }, "LogSection": { "additionalProperties": false, "description": "LOG section configuration.", "properties": { "API_LOG_FILE": { "default": "/var/log/qcos/qcos-api.log", "description": "API log file path", "title": "Api Log File", "type": "string" }, "LOG_FORMAT": { "default": "%(asctime)s %(levelname)s %(filename)s:%(lineno)s %(message)s", "description": "Log message format", "title": "Log Format", "type": "string" }, "LOG_ROTATE_MAX_SIZE_MB": { "default": 10, "description": "Log file max size in MB before rotation", "minimum": 1, "title": "Log Rotate Max Size Mb", "type": "integer" }, "LOG_ROTATE_BACKUP_COUNT": { "default": 10, "description": "Number of backup log files to keep", "minimum": 1, "title": "Log Rotate Backup Count", "type": "integer" }, "LOG_ROTATE_COMPRESSION": { "default": true, "description": "Enable log file compression", "title": "Log Rotate Compression", "type": "boolean" } }, "title": "LogSection", "type": "object" }, "MetricsServerSection": { "additionalProperties": false, "description": "METRICS_SERVER section configuration.", "properties": { "METRICS_SERVER_LISTEN_IP": { "default": "", "description": "Metrics server listen IP ('' for all addresses)", "title": "Metrics Server Listen Ip", "type": "string" }, "METRICS_SERVER_LISTEN_PORT": { "default": 19400, "description": "Metrics server listen port (1024-65535)", "maximum": 65535, "minimum": 1024, "title": "Metrics Server Listen Port", "type": "integer" } }, "title": "MetricsServerSection", "type": "object" }, "PrefectSection": { "additionalProperties": false, "description": "PREFECT section configuration.", "properties": { "PREFECT_API_URL": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": "http://127.0.0.1:4200/api", "description": "Prefect API URL", "title": "Prefect Api Url" }, "PREFECT_SERVER_DATABASE_CONNECTION_URL": { "db_connection_url": true, "default": "sqlite+aiosqlite:///var/qcos/db/prefect.db", "description": "Prefect database connection URL", "sensitive": true, "title": "Prefect Server Database Connection Url", "type": "string" }, "PREFECT_WORKER_QUERY_SECONDS": { "default": 30, "description": "Prefect worker query interval in seconds", "minimum": 1, "title": "Prefect Worker Query Seconds", "type": "integer" }, "PREFECT_WORKER_PREFETCH_SECONDS": { "default": 1, "description": "Prefect worker prefetch interval in seconds", "minimum": 1, "title": "Prefect Worker Prefetch Seconds", "type": "integer" }, "PREFECT_WORKER_HEARTBEAT_SECONDS": { "default": 30, "description": "Prefect worker heartbeat interval in seconds", "minimum": 1, "title": "Prefect Worker Heartbeat Seconds", "type": "integer" }, "PREFECT_LOCAL_STORAGE_PATH": { "default": "/var/qcos/storage", "description": "Prefect local storage path", "title": "Prefect Local Storage Path", "type": "string" }, "PREFECT_LOGGING_LEVEL": { "default": "INFO", "description": "Prefect logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)", "enum": [ "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL" ], "title": "Prefect Logging Level", "type": "string" } }, "title": "PrefectSection", "type": "object" }, "RedisSection": { "additionalProperties": false, "description": "REDIS section configuration.", "properties": { "REDIS_SERVER_IP": { "default": "127.0.0.1", "description": "Redis server IP address", "title": "Redis Server Ip", "type": "string" }, "REDIS_SERVER_PORT": { "default": 6379, "description": "Redis server port (1024-65535)", "maximum": 65535, "minimum": 1024, "title": "Redis Server Port", "type": "integer" } }, "title": "RedisSection", "type": "object" }, "SSLSection": { "additionalProperties": false, "description": "SSL section configuration.", "properties": { "USE_SSL": { "default": false, "description": "Enable HTTPS for API server", "title": "Use Ssl", "type": "boolean" }, "CERT_FILE": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "SSL certificate file path", "title": "Cert File" }, "KEY_FILE": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "SSL private key file path", "title": "Key File" }, "CACERT_FILE": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "SSL CA certificate file path (optional)", "title": "Cacert File" } }, "title": "SSLSection", "type": "object" }, "UsersSection": { "additionalProperties": false, "description": "USERS section configuration.", "properties": { "PASSWORD_EXPIRY_DAYS": { "default": 90, "description": "Password expiry days (0 = never expire)", "minimum": 0, "title": "Password Expiry Days", "type": "integer" }, "MAX_LOGIN_ATTEMPTS": { "default": 5, "description": "Maximum login attempts before account lockout", "minimum": 1, "title": "Max Login Attempts", "type": "integer" }, "MAX_LOGIN_LOGS": { "default": 10000, "description": "Maximum number of login logs to keep in database", "minimum": 100, "title": "Max Login Logs", "type": "integer" }, "LOCKOUT_DURATION_MINUTES": { "default": 30, "description": "Account lockout duration in minutes", "minimum": 1, "title": "Lockout Duration Minutes", "type": "integer" }, "ACCESS_CONTROL_MODEL_FILE": { "default": "/etc/qcos/roles/casbin_model.conf", "description": "Casbin access control model file path", "title": "Access Control Model File", "type": "string" }, "ACCESS_CONTROL_POLICY_FILE": { "default": "/etc/qcos/roles/policy.conf", "description": "Casbin access control policy file path", "title": "Access Control Policy File", "type": "string" }, "ADMIN_PASSWORD": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "Admin password (encrypted)", "sensitive": true, "title": "Admin Password" }, "JWT_AUTH_SECRET_KEY": { "default": "47pW_6k8A4iU1Z8-r8G2j4_xN9M5V3L7Q9p2X1Y4Z0A", "description": "JWT authentication secret key", "sensitive": true, "title": "Jwt Auth Secret Key", "type": "string" }, "JWT_AUTH_ALGORITHM": { "default": "HS256", "description": "JWT authentication algorithm (HS256, HS512, RS256, etc.)", "title": "Jwt Auth Algorithm", "type": "string" }, "ACCESS_TOKEN_EXPIRE_MINUTES": { "default": 30, "description": "Access token expiry time in minutes", "minimum": 1, "title": "Access Token Expire Minutes", "type": "integer" }, "REFRESH_TOKEN_EXPIRE_DAYS": { "default": 7, "description": "Refresh token expiry time in days", "minimum": 1, "title": "Refresh Token Expire Days", "type": "integer" } }, "title": "UsersSection", "type": "object" }, "VirtSection": { "additionalProperties": false, "description": "VIRT section configuration.", "properties": { "MAX_JOBS_PER_VIRTUAL_INSTANCE": { "default": 10, "description": "Maximum jobs per virtual instance", "minimum": 1, "title": "Max Jobs Per Virtual Instance", "type": "integer" }, "PASSWORD_SALT": { "default": "123456", "description": "Salt for password/encryption", "sensitive": true, "title": "Password Salt", "type": "string" } }, "title": "VirtSection", "type": "object" } }, "additionalProperties": false }
- Config:
extra: str = forbid
validate_assignment: bool = True
- Fields:
- field DEFAULT: DefaultSection [Optional]
- field API_SERVER: APIServerSection [Optional]
- field METRICS_SERVER: MetricsServerSection [Optional]
- field PREFECT: PrefectSection [Optional]
- field REDIS: RedisSection [Optional]
- field DATABASE: DatabaseSection [Optional]
- field USERS: UsersSection [Optional]
- field VIRT: VirtSection [Optional]
- field LOG: LogSection [Optional]
- field SSL: SSLSection [Optional]
- field DEVICES: DevicesSection [Optional]
- class wy_qcos.common.config.Config
基类:
objectQCOS Configuration Manager using Pydantic.
Manages configuration from TOML files with type validation, default values, and value ranges. Access is ALWAYS through Section:
示例
Config.DEFAULT.DEBUG Config.API_SERVER.API_SERVER_LISTEN_PORT Config.USERS.PASSWORD_EXPIRY_DAYS
- VALID_SECTIONS = ['DEFAULT', 'API_SERVER', 'METRICS_SERVER', 'PREFECT', 'REDIS', 'DATABASE', 'USERS', 'VIRT', 'LOG', 'SSL', 'DEVICES']
- DEFAULT: DefaultSection = DefaultSection(DEBUG=False, MAX_JOBS=10000, MAX_QUEUED_JOBS=1000, AUTH_MODE='no', VENV_DIR='/var/lib/qcos/venv')
- API_SERVER: APIServerSection = APIServerSection(API_WORKERS=8, API_SERVER_LISTEN_IP='', API_SERVER_LISTEN_PORT=18400)
- METRICS_SERVER: MetricsServerSection = MetricsServerSection(METRICS_SERVER_LISTEN_IP='', METRICS_SERVER_LISTEN_PORT=19400)
- PREFECT: PrefectSection = PrefectSection(PREFECT_API_URL='http://127.0.0.1:4200/api', PREFECT_SERVER_DATABASE_CONNECTION_URL='sqlite+aiosqlite:///var/qcos/db/prefect.db', 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')
- REDIS: RedisSection = RedisSection(REDIS_SERVER_IP='127.0.0.1', REDIS_SERVER_PORT=6379)
- DATABASE: DatabaseSection = DatabaseSection(QCOS_DATABASE_CONNECTION_URL='sqlite:////var/qcos/db/qcos.db?timeout=30&journal_mode=WAL')
- USERS: UsersSection = UsersSection(PASSWORD_EXPIRY_DAYS=90, MAX_LOGIN_ATTEMPTS=5, MAX_LOGIN_LOGS=10000, LOCKOUT_DURATION_MINUTES=30, ACCESS_CONTROL_MODEL_FILE='/etc/qcos/roles/casbin_model.conf', ACCESS_CONTROL_POLICY_FILE='/etc/qcos/roles/policy.conf', ADMIN_PASSWORD=None, JWT_AUTH_SECRET_KEY='47pW_6k8A4iU1Z8-r8G2j4_xN9M5V3L7Q9p2X1Y4Z0A', JWT_AUTH_ALGORITHM='HS256', ACCESS_TOKEN_EXPIRE_MINUTES=30, REFRESH_TOKEN_EXPIRE_DAYS=7)
- VIRT: VirtSection = VirtSection(MAX_JOBS_PER_VIRTUAL_INSTANCE=10, PASSWORD_SALT='123456')
- LOG: LogSection = LogSection(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)
- SSL: SSLSection = SSLSection(USE_SSL=False, CERT_FILE=None, KEY_FILE=None, CACERT_FILE=None)
- DEVICES: DevicesSection = DevicesSection(DEVICE_LIST=[])
- classmethod initialize()
Initialize Config with default values.
- classmethod load_config_file(config_file, extra_config=False)
Load configuration from TOML file.
- 参数:
config_file (str) -- Path to TOML configuration file
extra_config (bool) -- Whether to load as extra config (not in VALID_SECTIONS)
- 抛出:
GenericException -- If file cannot be read or config is invalid
- classmethod load_driver_env_file(config_file)
Load driver environment configuration file.
- 参数:
config_file (str) -- Path to driver env config file
- classmethod validate()
Validate current configuration.
- classmethod get_config()
Get the configuration model.
- 返回:
ConfigModel instance
- 返回类型:
ConfigModel | None
- classmethod get_extra_configs()
Get extra configurations.
- 返回:
Extra configs dictionary
- 返回类型:
dict[str, dict[str, Any]]
- classmethod get_driver_env_configs()
Get driver environment configurations.
- 返回:
Driver env configs dictionary
- 返回类型:
dict[str, Any]
- classmethod get_configs(mask_password=False)
Get all configurations as dictionary.
- 参数:
mask_password (bool) -- Whether to mask password values
- 返回:
Dictionary of all configurations (nested by section)
- 返回类型:
dict[str, Any]
- classmethod show_info()
Show configuration information with sensitive fields masked.
- 返回:
Formatted configuration information string with masked sensitive values
- 返回类型:
str
wy_qcos.common.constant module
- class wy_qcos.common.constant.Constant
基类:
objectConstants.
- 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_METRICS_SERVER_LISTEN_IP = ''
- DEFAULT_METRICS_SERVER_LISTEN_PORT = 19400
- DEFAULT_UPDATE_METRICS_INTERVAL_SECONDS = 5
- 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_USER_LENGTH = 2
- MAX_USER_LENGTH = 64
- MIN_ROLE_LENGTH = 2
- MAX_ROLE_LENGTH = 64
- MIN_DESCRIPTION_LENGTH = 1
- MAX_DESCRIPTION_LENGTH = 255
- MIN_PASSWORD_LENGTH = 6
- MAX_PASSWORD_LENGTH = 32
- 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_'
- DEVICE_MANAGER_PREFIX = 'device_mgr_'
- TRANSPILER_CMSS = 'cmss'
- TRANSPILER_HIGH_PERFORMANCE_CMSS = 'high_performance_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_TYPE_MACHINE = 'machine'
- PROFILING_TYPES = ['all', 'code', 'scheduling', 'driver:parse', 'driver:transpile', 'driver:run', 'machine']
- PROFILING_INFO = {'all': {'alias_name': '使能所有性能评估类型'}, 'code': {'alias_name': '作业中单代码执行耗时'}, 'driver:parse': {'alias_name': '代码解析耗时'}, 'driver:run': {'alias_name': '后端运行耗时'}, 'driver:transpile': {'alias_name': '转译器耗时'}, 'machine': {'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 = 100
- DEFAULT_DEVICE_MONITOR_RETRY_INTERVAL = 60
- DEFAULT_DEVICE_MONITOR_INTERVAL = 60
- AUTH_MODE_KEY = 'auth_mode'
- AUTH_MODE_NO = 'no'
- AUTH_MODE_JWT = 'jwt'
- AUTH_MODE_VIRTUAL_INSTANCE = 'virtual_instance'
- AUTH_MODES = ['no', 'jwt', 'virtual_instance']
- ADMIN_PROJECT_ID = '00000000-0000-4000-8000-000000000001'
- ADMIN_PROJECT_NAME = 'admin project'
- DEFAULT_PROJECT_ID = '00000000-0000-4000-8000-000000000000'
- DEFAULT_PROJECT_NAME = 'default project'
- ADMIN_USERNAME = 'admin'
- DEFAULT_ADMIN_PASSWORD = '123456'
- ANONYMOUS_USERNAME = 'anonymous'
- ENV_VAR_ACCESS_TOKEN = 'QCOS_ACCESS_TOKEN'
- JWT_AUTH_AUDIENCE = 'qcos-api'
- ROLE_ADMIN = 'admin'
- ROLE_USER = 'user'
- ROLE_ANY = '__any__'
- ALL_ROLES = ['admin', 'user']
- 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
- SYSTEM_HEALTHY = 'system_healthy'
- HEARTBEAT_TIMESTAMP = 'heartbeat_timestamp'
- COMPONENT_NAME_FASTAPI = 'fastapi'
- COMPONENT_NAME_REDIS = 'redis'
- COMPONENT_NAME_PREFECT = 'prefect'
- COMPONENT_NAME_WORKER = 'worker'
- COMPONENT_NAMES = ['fastapi', 'redis', 'prefect', 'worker']
- COMPONENT_STATUS = 'component_status'
- COMPONENT_STATUS_ONLINE = 'online'
- COMPONENT_STATUS_OFFLINE = 'offline'
- JOB_METRICS_FIELD_TOTAL = 'total'
- JOB_METRICS_FIELD_COMPLETED = 'completed'
- JOB_METRICS_FIELD_FAILED = 'failed'
- JOB_METRICS_FIELD_RUNNING = 'running'
- JOB_METRICS_FIELD_QUEUED = 'queued'
- JOB_METRICS_FIELD_CANCELLING = 'cancelling'
- JOB_METRICS_FIELD_CANCELLED = 'cancelled'
- JOB_METRICS_FIELD_DELETED = 'deleted'
- JOB_METRICS_FIELD_UNKNOWN = 'unknown'
- API_METRICS_REQUESTS_TOTAL = 'api_requests_total'
- API_METRICS_REQUESTS_IN_PROGRESS = 'api_requests_in_progress'
- API_METRICS_REQUESTS_DURATION = 'api_request_duration'
- API_TOTAL_REQUESTS = 'total_requests'
- API_LAST_HOUR_REQUESTS = 'last_hour_requests'
- API_LAST_DAY_REQUESTS = 'last_day_requests'
- class wy_qcos.common.constant.HttpHeaders
基类:
object- DEFAULT_JSON_HEADERS = {'Accept': 'application/json', 'Content-Type': 'application/json'}
- class wy_qcos.common.constant.HttpMethod
基类:
objectHTTP methods.
- GET = 'get'
- POST = 'post'
- PUT = 'put'
- PATCH = 'patch'
- DELETE = 'delete'
- class wy_qcos.common.constant.HttpCode
基类:
objectHTTP 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)
基类:
ExceptionBase exception.
- get_error_code()
Get error code.
- 返回:
error code
- get_err_msgs()
- exception wy_qcos.common.errors.GenericException(message)
-
Generic exception.
- module_name = 'Generic'
- error_code = -10
- err_type = 'Error'
- exception wy_qcos.common.errors.InvalidArguments(message)
-
Invalid arguments.
- module_name = 'Generic'
- error_code = -11
- err_type = 'Invalid arguments'
- exception wy_qcos.common.errors.NotFound(message)
-
Not Found.
- module_name = 'Generic'
- error_code = -12
- err_type = 'Not Found'
- exception wy_qcos.common.errors.WorkFlowError(message)
-
Work Flow Error.
- module_name = 'Workflow'
- error_code = -13
- err_type = 'Error'
- exception wy_qcos.common.errors.JobEngineDriverInitError(message)
-
Job Engine: Driver Init Error.
- module_name = 'JobEngine'
- error_code = -100
- err_type = 'Driver Init Error'
- exception wy_qcos.common.errors.JobEngineTranspilerInitError(message)
-
Job Engine: Transpiler Init Error.
- module_name = 'JobEngine'
- error_code = -101
- err_type = 'Transpiler Init Error'
- exception wy_qcos.common.errors.JobEngineParseError(message)
-
Job Engine: Parse Error.
- module_name = 'JobEngine'
- error_code = -102
- err_type = 'Parse Error'
- exception wy_qcos.common.errors.JobEngineTranspileError(message)
-
Job Engine: Transpile Error.
- module_name = 'JobEngine'
- error_code = -103
- err_type = 'Transpile Error'
- exception wy_qcos.common.errors.JobEngineDriverRunError(message)
-
Job Engine: Driver Run Error.
- module_name = 'JobEngine'
- error_code = -104
- err_type = 'Driver Run Error'
- exception wy_qcos.common.errors.JobEngineCheckWidthError(message)
-
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)
-
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)
-
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)
-
Job Engine: Check Matrix Error.
- module_name = 'JobEngine'
- error_code = -108
- err_type = 'Check Matrix Error'
- exception wy_qcos.common.errors.JobEngineCircuitCuttingError(message)
-
Job Engine: Circuit Cutting Error.
- module_name = 'JobEngine'
- error_code = -109
- err_type = 'Circuit Cutting Error'
- exception wy_qcos.common.errors.JobEngineReconProbError(message)
-
Job Engine: Reconstruct Probability Error.
- module_name = 'JobEngine'
- error_code = -110
- err_type = 'Reconstruct Probability Error'
- exception wy_qcos.common.errors.JobEngineCompileError(message)
-
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
基类:
objectLibrary.
- 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_from_pydantic(data_obj, mask_value='*' * 8)
Mask password from Pydantic model.
sensitive=True: replace entire field with mask_value
db_connection_url=True: mask password in URL
no marker: return original value
- 参数:
data_obj -- Pydantic data object
mask_value -- Mask value, default "****"
- 返回:
Dictionary with masked sensitive values (original dict unchanged)
- 返回类型:
dict
- static mask_password(configs, password_replace='*' * 8, keys_to_match='^(?:_.*|.*(password|secret|hidden|salt|.*connection_url).*)$')
Mask password and sensitive values.
- 参数:
configs -- configs
password_replace -- password text to be replaced
keys_to_match -- keys to be matched (regular expression)
- 返回:
replaced configs with masked sensitive values
- 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
基类:
objectQCOS Version.
- VERSION = '1.1.0'