ultipa.utils package

Subpackages

Submodules

ultipa.utils.ResposeFormat module

class ultipa.utils.ResposeFormat.ResponseKeyFormat(jsonKeys: List[str] | None = None, boolKeys: List[str] | None = None, keyReplace: object | None = None, dataFormat: List[str] | None = None, convert2Int: List[str] | None = None)[source]

Bases: object

Processing class that defines settings for returnd-data formatting related operations.

changeKeyValue(objs)[source]

ultipa.utils.checkStrTime module

ultipa.utils.checkStrTime.is_valid_date(strdate)[source]

Judge whether a string is a valid data or time.

ultipa.utils.common module

Settings of some constant values.

ultipa.utils.convert module

class ultipa.utils.convert.Any[source]

Bases: BaseModel

Any model

ultipa.utils.convert.convertTableToDict(table_rows, headers)[source]

Convert Table to Object.

Args:

table_rows: headers:

Returns:

ultipa.utils.convert.convertToAnyObject(dict1: dict)[source]

Convert Dict to Object.

Args:

dict1:

Returns:

ultipa.utils.convert.convertToListAnyObject(list1: List[dict])[source]

Convert List[Dict] to Object.

Args:

list1:

Returns:

ultipa.utils.errors module

exception ultipa.utils.errors.ParameterException(err='Parameter error!')[source]

Bases: Exception

Class for customizing errors related to parameter

exception ultipa.utils.errors.SerializeException(err='Serialize failed!')[source]

Bases: Exception

Class for customizing errors related to serialization

exception ultipa.utils.errors.ServerException(err='Server connection failed!')[source]

Bases: Exception

Class for customizing errors related to server connection

exception ultipa.utils.errors.SettingException(err='Setting error!')[source]

Bases: Exception

Class for customizing errors related to settings

ultipa.utils.errors.checkError(error: str)[source]

Method for customizing errors related to parameter validation

ultipa.utils.fileSize module

ultipa.utils.fileSize.read_in_chunks(filePath, chunk_size=1048576)[source]

Lazy function (generator) to read a file piece by piece. Default chunk size: 1M You can set your own chunk size

ultipa.utils.format module

class ultipa.utils.format.DataMerge[source]

Bases: object

static arrayDiff(arr1: [str], arr2: [str])[source]
static concat(arr1: list, arr2: list, bykey: str = None, ignoreKeys: [str] = None)[source]
static customizer(objValue, srcValue, key, ignoreKeys)[source]
static merge(o1: object, o2: object, ignoreKeys: [<class 'str'>] = None)[source]
class ultipa.utils.format.FormatResponse[source]

Bases: object

static formatStatisticsTable(table: Table)[source]
static resTableToArray(table: Table)[source]
class ultipa.utils.format.FormatType[source]

Bases: object

static Response(_res, host: str | None = None) Response[source]
static arrays(_arrays) List[ArrayAlias][source]
static attr(attr, timeZone, timeZoneOffset) UltipaAttr[source]
static attrAlias(_attrs, timeZone, timeZoneOffset) List[AttrNewAlias][source]
static attrAlias1(_attrs) List[Attr][source]
static attrEdgeEntityTable(data) List[Edge][source]
static attrEntity(entityRows, type: str)[source]
static attrNodeEntityTable(data) List[Node][source]
static attrPath(_paths, timeZone, timeZoneOffset) [<class 'ultipa.structs.Path.Path'>][source]
static checkEdgeRow(i: int, schema: Schema, row: EntityRow)[source]
static checkEntityEdgeRow(i: int, schema: Schema, row: EntityRow)[source]
static checkEntityNodeRow(i: int, schema: Schema, row: EntityRow)[source]
static checkNodeRow(i: int, schema: Schema, row: EntityRow)[source]
static checkProperty(row, schemaProperties)[source]
static downloadResponse(_res) Response[source]
static edgeAliases(_edges, timeZone, timeZoneOffset) List[EdgeAlias][source]
static edgeTable(edgeTableData, timeZone, timeZoneOffset)[source]
static explainPlan(_explainPlan) List[ExplainPlan][source]
static exportResponse(_res, timeZone, timeZoneOffset) Response[source]
static export_edges(_edges, timeZone, timeZoneOffset) List[source]
static export_nodes(_nodes, timeZone, timeZoneOffset) List[source]
static getRaftStatus(data: dict) Status[source]
static graphPrivileges(graphPrivileges: [object])[source]
static makeEntityEdgeTable(schema: Schema, rows: List[EntityRow], timeZoneOffset=None) EdgeEntityTable[source]
static makeEntityNodeTable(schema: Schema, entity_rows: List[EntityRow], timeZoneOffset=None) NodeEntityTable[source]
static mergeUqlResponse(mergeRes: Response, res: Response)[source]
static nodeAliases(_nodes, timeZone, timeZoneOffset) List[NodeAlias][source]
static nodeTable(nodeTableData, timeZone, timeZoneOffset)[source]
classmethod parseAttr(attr, aliasName) Attr[source]
classmethod parseAttrAlias(attrAlias) Attr[source]
classmethod parseAttrListData(datas) List[PaserAttrListData][source]
static pathAlias(_paths, timeZone, timeZoneOffset) [<class 'ultipa.structs.Path.PathAlias'>][source]
static pathScheams(path)[source]
static propertyType(type: str) PropertyType[source]

Convert the type input by the user to ULTIPA.PropertyType :param type: :return:

static response(uql_response: Response, uqlReply, timeZone, timeZoneOffset) Response[source]
static resultalias(_arrays) List[ResultAlias][source]
static statistics(_table, timeZone, timeZoneOffset) UltipaStatistics[source]
static status(_status, host: str | None = None) Status[source]
static table(_table, timeZone, timeZoneOffset) Table[source]
static tables(_tables, timeZone, timeZoneOffset) List[Table][source]
static uqlMergeResponse(_res, timeZone, timeZoneOffset) UltipaResponse[source]
static uqlResponse(_res, timeZone, timeZoneOffset) UltipaResponse[source]
static values(_values) dict[source]
class ultipa.utils.format.HasDataMap(has_ultipa_data, has_attr_data, only_attr_list)[source]

Bases: object

has_attr_data: bool
has_ultipa_data: bool
only_attr_list: bool

ultipa.utils.logger module

class ultipa.utils.logger.LoggerConfig(name: str, fileName: str | None = None, isWriteToFile: bool = False, level: <module 'logging' from '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/logging/__init__.py'> = 20, isStream: bool = False)[source]

Bases: object

A class that defines how log messages related to Ultipa connection are handled.

It specifies settings such as log name, log file paths, log level, etc.

getlogger()[source]

ultipa.utils.nullValue module

ultipa.utils.nullValue.isNullValue(v: any, type: PropertyType)[source]

Judge whether a value is null

Args:

v: The value to be judged type: The property type of v

Returns:

bool

ultipa.utils.nullValue.nullValue(type: PropertyType)[source]

Returns the null value corresponding to different data types

Args:

type: The data type

Returns:

ultipa.utils.password2md5 module

ultipa.utils.password2md5.passwrod2md5(password: str)[source]

Use the MD5 algorithm to encrypt user password

Args:

password:

Returns:

ultipa.utils.privileges module

class ultipa.utils.privileges.GraphPrivileges[source]

Bases: object

Data class for graphset privileges.

AB = 'AB'
ALGO = 'ALGO'
ALTER_PROPERTY = 'ALTER_PROPERTY'
ALTER_SCHEMA = 'ALTER_SCHEMA'
AUTONET = 'AUTONET'
CLEAR_TASK = 'CLEAR_TASK'
CREATE_FULLTEXT = 'CREATE_FULLTEXT'
CREATE_INDEX = 'CREATE_INDEX'
CREATE_PROPERTY = 'CREATE_PROPERTY'
CREATE_SCHEMA = 'CREATE_SCHEMA'
DELETE = 'DELETE'
DROP_FULLTEXT = 'DROP_FULLTEXT'
DROP_INDEX = 'DROP_INDEX'
DROP_PROPERTY = 'DROP_PROPERTY'
DROP_SCHEMA = 'DROP_SCHEMA'
EXPORT = 'EXPORT'
FIND = 'FIND'
INSERT = 'INSERT'
KHOP = 'KHOP'
LTE = 'LTE'
PAUSE_TASK = 'PAUSE_TASK'
RESUME_TASK = 'RESUME_TASK'
SHOW_ALGO = 'SHOW_ALGO'
SHOW_FULLTEXT = 'SHOW_FULLTEXT'
SHOW_INDEX = 'SHOW_INDEX'
SHOW_PROPERTY = 'SHOW_PROPERTY'
SHOW_SCHEMA = 'SHOW_SCHEMA'
SHOW_TASK = 'SHOW_TASK'
SPREAD = 'SPREAD'
STOP_TASK = 'STOP_TASK'
TEMPLATE = 'TEMPLATE'
UFE = 'UFE'
UPDATE = 'UPDATE'
UPSERT = 'UPSERT'
class ultipa.utils.privileges.SystemPrivileges[source]

Bases: object

Data class for system privileges.

ALTER_GRAPH = 'ALTER_GRAPH'
ALTER_POLICY = 'ALTER_POLICY'
ALTER_USER = 'ALTER_USER'
COMPACT = 'COMPACT'
CREATE_GRAPH = 'CREATE_GRAPH'
CREATE_POLICY = 'CREATE_POLICY'
CREATE_USER = 'CREATE_USER'
DROP_GRAPH = 'DROP_GRAPH'
DROP_POLICY = 'DROP_POLICY'
DROP_USER = 'DROP_USER'
KILL = 'KILL'
MOUNT_GRAPH = 'MOUNT_GRAPH'
SHOW_GRAPH = 'SHOW_GRAPH'
SHOW_POLICY = 'SHOW_POLICY'
SHOW_PRIVILEGE = 'SHOW_PRIVILEGE'
SHOW_USER = 'SHOW_USER'
STAT = 'STAT'
TOP = 'TOP'
TRUNCATE = 'TRUNCATE'
UNMOUNT_GRAPH = 'UNMOUNT_GRAPH'

ultipa.utils.propertyUtils module

ultipa.utils.propertyUtils.getPropertyTypesDesc(type: PropertyTypeStr, subTypes: List[PropertyTypeStr])[source]

Generate the format string a list type corresponds to.

Args:

type:

subTypes:

Returns:

str[]

ultipa.utils.propertyUtils.isBasePropertyType(type: PropertyTypeStr)[source]

Judge whether a data type is a base property type (not a list).

Args:

type:

Returns:

ultipa.utils.raftRetry module

class ultipa.utils.raftRetry.RetryHelp[source]

Bases: object

Configuration class that defines settings for the retry mechanism.

static check(conn, requestConfig, response) RetryResponse[source]
static checkRes(response)[source]
currentRetry: Retry = None
static getRty(requestConfig)[source]

ultipa.utils.serialize module

ultipa.utils.typeCheck module

class ultipa.utils.typeCheck.TypeCheck[source]

Bases: object

Check the data type.

static checkProperty(type, value)[source]

ultipa.utils.ultipaSchedule module

ultipa.utils.ultipaSchedule.background_job()[source]
ultipa.utils.ultipaSchedule.run_continuously(interval=2)[source]

Continuously run, while executing pending jobs at each elapsed time interval. @return cease_continuous_run: threading. Event which can be set to cease continuous run. Please note that it is intended behavior that run_continuously() does not run missed jobs. For example, if you’ve registered a job that should run every minute and you set a continuous run interval of one hour then your job won’t be run 60 times at each interval but only once.

ultipa.utils.ultipa_datetime module

class ultipa.utils.ultipa_datetime.DateTimestamp(date=None)[source]

Bases: object

A class that realizes the mutual conversion of datetime and timestamp.

class ultipa.utils.ultipa_datetime.UTC(offsetHours=0, offsetSeconds=0)[source]

Bases: tzinfo

dst(dt)[source]

datetime -> DST offset as timedelta positive east of UTC.

tzname(dt)[source]

datetime -> string name of time zone.

utcoffset(dt)[source]

datetime -> timedelta showing offset from UTC, negative values indicating West of UTC

class ultipa.utils.ultipa_datetime.UltipaDatetime[source]

Bases: object

Processing class for date and time related operations.

static datetimeInt2datetimeStr(datetime_int)[source]

Convert the customized datetime integer into a datetime string

Args:

datetime_int:

Returns:

classmethod datetimeStr2datetimeInt(strDatetime: datetime)[source]

Convert a datatime string into a customized datatime integer.

Args:

strDatetime:

Returns:

day = 0
hour = 0
microsecond = 0
minute = 0
month = 0
second = 0
static timestampInt2timestampStr(datetime_int, timeZone: str | None = None, timeZoneOffset: int = 0)[source]
classmethod timestampStr2timestampInt(strDatetime: str, timeZone, timeZoneOffset=0)[source]

Convert strings of datetime, timezone and timezone-offset into the Unix timestamp integer in seconds.

Args:

strDatetime: timeZone: timeZoneOffset:

Returns:

year = 0
ultipa.utils.ultipa_datetime.getTimeOffsetSeconds(timeZoneOffset)[source]
ultipa.utils.ultipa_datetime.getTimeZoneOffset(requestConfig, defaultConfig)[source]

Get timezone offset

Args:

requestConfig:

defaultConfig:

Returns:

ultipa.utils.ultipa_datetime.getTimeZoneSeconds(timeZone)[source]
ultipa.utils.ultipa_datetime.wrapper(func)[source]

Measures the execution time of a method.

Args:

func:

Returns:

ultipa.utils.uql_marker module

class ultipa.utils.uql_marker.CommandList[source]

Bases: object

ab = 'ab'
algo = 'algo'
algo_dv = 'algo_dv'
alterEdgeProperty = 'alter().edge_property'
alterEdgeSchema = 'alter().edge_schema'
alterGraph = 'alter().graph'
alterNodeProperty = 'alter().node_property'
alterNodeSchema = 'alter().node_schema'
alterPolicy = 'alter().policy'
alterUser = 'alter().user'
autoNet = 'autoNet'
autoNetByPart = 'autoNetByPart'
clearTask = 'clear().task'
compact = 'compact'
createBackup = 'db.backup.create'
createEdgeFulltext = 'create().edge_fulltext'
createEdgeIndex = 'create().edge_index'
createEdgeProperty = 'create().edge_property'
createEdgeSchema = 'create().edge_schema'
createGraph = 'create().graph'
createNodeFulltext = 'create().node_fulltext'
createNodeIndex = 'create().node_index'
createNodeProperty = 'create().node_property'
createNodeSchema = 'create().node_schema'
createPolicy = 'create().policy'
createUser = 'create().user'
deleteEdges = 'delete().edges'
deleteNodes = 'delete().nodes'
dropEdgeFulltext = 'drop().edge_fulltext'
dropEdgeIndex = 'drop().edge_index'
dropEdgeProperty = 'drop().edge_property'
dropEdgeSchema = 'drop().edge_schema'
dropGraph = 'drop().graph'
dropNodeFulltext = 'drop().node_fulltext'
dropNodeIndex = 'drop().node_index'
dropNodeProperty = 'drop().node_property'
dropNodeSchema = 'drop().node_schema'
dropPolicy = 'drop().policy'
dropUser = 'drop().user'
edges = 'find().edges'
getPolicy = 'show().policy'
getSelfInfo = 'show().self'
getUser = 'show().user'
grant = 'grant'
grantUser = 'grant().user'
insert = 'insert'
khop = 'khop'
kill = 'kill'
lteEdge = 'LTE().edge_property'
lteNode = 'LTE().node_property'
mount = 'mount().graph'
nodeSpread = 'spread'
nodes = 'find().nodes'
pauseTask = 'pause().task'
restoreBackup = 'db.backup.restore'
resumeTask = 'resume().task'
revoke = 'revoke().user'
showAlgo = 'show().algo'
showBackup = 'db.backup.show'
showEdgeFulltext = 'show().edge_fulltext'
showEdgeIndex = 'show().edge_index'
showEdgeProperty = 'show().edge_property'
showEdgeSchema = 'show().edge_schema'
showFulltext = 'show().fulltext'
showGraph = 'show().graph'
showIndex = 'show().index'
showNodeFulltext = 'show().node_fulltext'
showNodeIndex = 'show().node_index'
showNodeProperty = 'show().node_property'
showNodeSchema = 'show().node_schema'
showPolicy = 'show().policy'
showPrivilege = 'show().privilege'
showProperty = 'show().property'
showSchema = 'show().schema'
showTask = 'show().task'
showUser = 'show().user'
stat = 'stats'
stopTask = 'stop().task'
template = 't'
top = 'top'
truncate = 'truncate'
ufeEdge = 'UFE().edge_property'
ufeNode = 'UFE().node_property'
unmount = 'unmount().graph'
updateEdges = 'update().edges'
updateNodes = 'update().nodes'
upsert = 'upsert'
class ultipa.utils.uql_marker.UQL[source]

Bases: object

static parse(uqlStr)[source]

Parse UQL.

Args:

uqlStr: A uql statement

Returns:

static parse_globle(uqlStr)[source]
static uqlObjectExample(uqlStr)[source]
class ultipa.utils.uql_marker.UQLMAKER(command: CommandList, commandP: any | None = None, commonParams=None)[source]

Bases: object

A class that assembles UQL.

static PointFunction(latitude: float, longitude: float)[source]
static PointString(latitude: float, longitude: float)[source]
addParam(key: str, value: any, required: bool = True, notQuotes=False)[source]
addTemplateParams(templateParams: List[object])[source]
setCommandParams(commandP: any)[source]
toString()[source]
class ultipa.utils.uql_marker.UQLParmas[source]

Bases: object

getCommands(index)[source]
getCommandsParam(index)[source]
getFirstCommands()[source]
getSecondCommands()[source]

Module contents