towhee.utils.repo_normalize.RepoNormalize

class towhee.utils.repo_normalize.RepoNormalize(uri: str)[source]

Bases: object

To normalize the repo.

Parameters:

uri (str) – The uri of the repo.

Methods

check_repo

Check if the repo name matches the format.

check_uri

Check if the uri matches the format.

get_full_uri

Get the full uri.

get_name

Get the name for repo: normalized repo name, module name, and class name.

get_op

Get the required name for operator: normalized repo name, python file name, yaml file name and class name.

get_pipeline

Get the required name for pipeline: normalized repo name and yaml file name.

mapping

Mapping the path(endswith']'), like repo[framework] to repo-framework.

parse_uri

Parse the uri.

url_valid

Attributes

has_ns

__init__(uri: str)[source]
static check_repo(repo: str) bool[source]

Check if the repo name matches the format.

Parameters:

repo (str) – Repo name.

Returns:

(bool)

Check if matched.

Raises:

(ValueError) – Raise error if false.

check_uri() bool[source]

Check if the uri matches the format.

Returns:

(bool)

Check if passed.

Raises:

(ValueError) – Raise error when false.

get_full_uri() str[source]

Get the full uri.

Returns:

(str)

The full uri from self._uri.

static get_name(repo: str) OpResult[source]

Get the name for repo: normalized repo name, module name, and class name.

Parameters:

repo (str) – Repo name.

Returns:

(NamedTuple[str, str, str])

Return the name for repo: repo_name, module_name, class_name.

static get_op(repo: str) OpResult[source]

Get the required name for operator: normalized repo name, python file name, yaml file name and class name.

Parameters:

repo (str) – Repo name.

Returns:

(NamedTuple[str, str, str, str])

Return the required name for operator: repo, py_file, yaml_file, class_name.

static get_pipeline(repo: str) PipelineResult[source]

Get the required name for pipeline: normalized repo name and yaml file name.

Parameters:

repo (str) – Repo name.

Returns:

(NamedTuple[str, str])

Return the required name for operator: repo, yaml_file.

static mapping(path: str) str[source]

Mapping the path(endswith’]’), like repo[framework] to repo-framework.

Parameters:

path (str) – The path to the uri.

Returns:

(str)

Check if passed.

Raises:

(ValueError) – Raise error when the path does not match the format.

parse_uri() ParseResult[source]

Parse the uri.

Returns:

(NamedTuple[str, str, str, str, str, str, str, str, str, str, dict])

Return the full_uri and its components: author, repo, ref, repo_type, norm_repo, module_name, class_name, scheme, netloc, query.