omni.flux.utils.common#

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

async omni.flux.utils.common.api.send_request(
method: str,
endpoint: str,
raw_response: bool = False,
**kwargs,
) Response | dict#

Send an HTTP request to a server.

The server’s address will be taken from the omni.services.transport.server.http settings.

Parameters:
  • method – HTTP method to use

  • endpoint – HTTP endpoint to send the request to

  • **kwargs – Additional keyword arguments to pass to the requests.request function

Raises:

RuntimeError – If the request fails

Returns:

The JSON response from the server

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

omni.flux.utils.common.decorators.ignore_function_decorator(attrs: list[str] | None = None)#

This decorator will break the infinite loop if a function calls itself

Parameters:

attrs – list of attributes

omni.flux.utils.common.decorators.ignore_function_decorator_and_reset_value(
attrs: dict[str, bool] | None = None,
)#

This decorator will break the infinite loop if a function calls itself. If the given attribute already exist and have a True value, we can set a new value to it

Parameters:

attrs – list of attributes

omni.flux.utils.common.decorators.ignore_function_decorator_async(attrs: list[str] | None = None)#

This decorator will break the infinite loop if a function calls itself

Parameters:

attrs – list of attributes

omni.flux.utils.common.decorators.limit_recursion(
num_allowed_recursive_calls: int = 0,
error: bool = False,
)#

This decorator is used to restrict the number of recursive calls a function can make.

Any returned value from the decorated method is discarded.

Kwargs:
num_allowed_recursive_calls (int): The maximum allowed depth for recursion in this decorated function. The

value does not include the initial call. Default value is zero which means any recursive calls are ignored.

error (bool): If True and number of recursive call exceeds num_allowed_recursive_calls then a RecursionError

is raised.

Raises:

RecursionError – If error is True and number of recursive calls exceeds num_allowed_recursive_calls.

Examples: >>> @limit_recursion(num_allowed_recursive_calls=2) >>> def inc(store, i=0): … i += 1 … store.append(i) … inc(store, i) >>> cache = [] >>> inc(cache) >>> assert cache == [1, 2, 3]

omni.flux.utils.common.decorators.sandwich_attrs_function_decorator(attrs: list[str] | None = None)#

Set new attributes before and after that the function is executed

Parameters:

attrs – list of attributes to set

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

class omni.flux.utils.common.event.Event(*args, copy: bool = False, **kwargs)#

A list of callable objects. Calling an instance of this will cause a call to each item in the list in ascending order by index.

class omni.flux.utils.common.event.EventSubscription(event, function)#

Holds an Event subscription, auto-unsubscribed when no longer referenced and gets destroyed by GC.

Event holds the callback while this object exists.

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

omni.flux.utils.common.git.clone_repository(
repository_url: str,
output_directory: str,
branch: str | None = None,
depth: int | None = None,
recurse_submodules: bool = False,
validation_callback: Callable[[str], bool] | None = None,
) pygit2.Repository | None#

Clone a git repository to a local directory.

Parameters:
  • repository_url – The repository URL to clone from.

  • output_directory – Destination directory.

  • branch – Optional branch name to check out after clone.

  • depth – Optional shallow clone depth (e.g., 1 for latest snapshot).

  • recurse_submodules – If True, recursively clone all submodules.

  • validation_callback – An optional callback function that validates the repository root.

Raises:

ValueError – If the repository URL does not end with .git

Returns:

A Repository instance, or None if the clone fails.

omni.flux.utils.common.git.get_branch(repository: pygit2.Repository | None) str | None#

Get the current git branch.

Parameters:

repository – A Repository instance, or None if discovery/open fails.

Returns:

The git branch, or None if the branch cannot be found. Returns “HEAD” if detached.

omni.flux.utils.common.git.get_local_commit(
repository: pygit2.Repository | None,
) pygit2.Oid | None#

Return the local commit (HEAD) as a pygit2.Oid or None.

Parameters:

repository – A Repository instance, or None if discovery/open fails.

Returns:

The Oid for the HEAD commit

omni.flux.utils.common.git.get_remote_ahead_behind(
repository: pygit2.Repository | None,
) tuple[int, int]#

Get the number of commits the local branch is ahead and behind the remote branch.

Parameters:

repository – A Repository instance, or None if discovery/open fails.

Raises:
  • ValueError – if the comparison cannot be made (e.g., no remote configured, no network, or commits are equal).

  • pygit2.GitError – If the remote commit cannot be fetched.

Returns:

A tuple of (ahead, behind) counts

omni.flux.utils.common.git.get_remote_commit(
repository: pygit2.Repository | None,
) pygit2.Oid | None#

Fetch and return the latest remote commit for the current branch (origin/<branch>) as a pygit2.Oid, or None if unavailable.

Parameters:

repository – A Repository instance, or None if discovery/open fails.

Raises:

pygit2.GitError – If the remote commit cannot be fetched.

Returns:

The Oid for the latest remote commit on the current branch

omni.flux.utils.common.git.has_local_changes(repository: pygit2.Repository | None) bool#

Check if the repository has local changes (uncommitted changes or non-pushed commits).

This is a convenience method that combines has_uncommitted_changes() and is_ahead_of_remote().

Parameters:

repository – A Repository instance, or None if discovery/open fails.

Returns:

True if there are uncommitted changes or non-pushed commits, False otherwise.

omni.flux.utils.common.git.has_uncommitted_changes(repository: pygit2.Repository | None) bool#

Check if the repository has uncommitted changes (modified or staged files).

This checks for differences between HEAD and the index, and between the index and the working directory. Untracked files are intentionally ignored.

Parameters:

repository – A Repository instance, or None if discovery/open fails.

Returns:

True if there are uncommitted changes, False otherwise.

omni.flux.utils.common.git.initialize_submodules(repository: pygit2.Repository | None) bool#

Initialize and update all the submodules in the repository.

Parameters:

repository – The repository instance to initialize submodules for.

Returns:

True if the submodules were initialized and updated successfully, False otherwise.

omni.flux.utils.common.git.open_repository(
repo_root: str | None = None,
validation_callback: Callable[[str], bool] | None = None,
) pygit2.Repository | None#

Discover and open the current git repository.

Parameters:
  • repo_root – The root directory of the repository to open. If None, the current working directory or any parent directory containing a .git directory is used.

  • validation_callback – An optional callback function that validates the repository root.

Returns:

A Repository instance, or None if discovery/open fails.

omni.flux.utils.common.git.pull_repository(
repository: pygit2.Repository | None,
force: bool = False,
) bool#

Pull the latest changes from the remote repository.

This function follows a simple workflow: 1. Stash any uncommitted changes (unless force=True) 2. If not ahead of remote: fast-forward to remote 3. If ahead of remote: rebase local commits onto remote 4. Unstash changes

The operation is atomic - either succeeds completely or leaves the repository in its original state with original uncommitted changes intact.

Parameters:
  • repository – A Repository instance, or None if discovery/open fails.

  • force – If True, discards all local changes and commits, performing a hard reset to remote. If False (default), attempts to preserve and rebases local commits.

Returns:

True if the pull was successful or already up to date, False if the pull failed. On failure, errors are logged and the repository is restored to its original state.

omni.flux.utils.common.git.rebase_repository(
repository: pygit2.Repository | None,
local_oid: pygit2.Oid,
remote_oid: pygit2.Oid,
) bool#

Rebase local commits onto a remote branch using cherry-pick operations.

This function performs a manual rebase by: 1. Finding the merge base (common ancestor) between local and remote 2. Collecting all local commits that need to be rebased 3. Resetting to the remote branch 4. Cherry-picking each local commit onto the new base

The operation is atomic - if any step fails, the repository is restored to its original state.

Parameters:
  • repository – The repository instance to rebase.

  • local_oid – The OID of the local HEAD (starting point).

  • remote_oid – The OID of the remote HEAD (target base).

Returns:

True if the rebase was successful, False if the rebase failed (e.g., conflicts detected, no common ancestor found).

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

omni.flux.utils.common.layer_utils.save_layer_as(context_name: str, replace: bool, layer_weakref: <module 'weakref' from '/home/gitlab-runner/.cache/packman/python/3.10.5-1-linux-x86_64/lib/python3.10/weakref.py'>, parent_weakref: <module 'weakref' from '/home/gitlab-runner/.cache/packman/python/3.10.5-1-linux-x86_64/lib/python3.10/weakref.py'>, on_save_done: ~collections.abc.Callable[[bool, str, list[str]], None], file_path: str)#

Save layer as new layer.

Parameters:
  • context_name – The context name.

  • replace – After saving the layer, should it replace the current layer in the stage.

  • layer_weakref – Weakref to the layer to be saved as.

  • parent_weakref – Weakref to the parent of the layer to be saved as.

  • on_save_done – Callback for when an error occurs or the file is saved successfully. Parameters of the callback are: Success, ErrorMessage, LayerIdentifiers

  • file_path – path to the new layer file to be saved

omni.flux.utils.common.layer_utils.validate_edit_target(context_name: str)#

Validate the edit target is in layer stack or session layer.

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

class omni.flux.utils.common.lights.LightTypes(value)#

The various USD Lux light types and their display names.

omni.flux.utils.common.lights.get_light_type(
class_name: str,
) LightTypes | None#

Get the LightTypes enum value for a given USD Lux light class name.

Parameters:

class_name – The USD Lux class name. Can be obtained by executing prim.GetTypeName()

Returns:

The LightTypes, or None if not found.

  • SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

omni.flux.utils.common.materials.get_materials_from_prim_paths(
prim_paths: list[str],
context_name: str = '',
) list[Material | MaterialBindingAPI | None]#

For each str prim path, get the materials that are used by the prim.

Parameters:
  • prim_paths – list of str

  • context_name – str

Returns:

list of UsdShade.Material, UsdShade.MaterialBindingAPI, or None

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

class omni.flux.utils.common.omni_url.OmniUrl(url: str | Path | 'OmniUrl', list_entry=None)#

A class to present a pathlib like wrapper around omni client urls.

delete()#

Delete the item and wait for the result.

property entry: ListEntry | None#

returns True if path points to a file.

property exists: bool#

return True if the file or folder exists.

property is_directory: bool#

returns True if path points to a directory.

property is_file: bool#

returns True if path points to a file.

iterdir() Generator[OmniUrl]#

When the path points to a directory, yield path objects of the directory contents.

property name: str#

The final path component, if any.

property parent_url: str#

return the folder that contains this url

property stem: str#

The final path component, minus its suffix(s).

property suffix: str#

The final component’s last suffix, if any.

This includes the leading period. For example: ‘.txt’

property suffixes: list[str]#

A list of the path’s file extensions

This includes the leading period. For example: [‘.tar’, ‘.gz’]

with_name(
name: str,
) OmniUrl#

Return a new url with the url path final component changed.

with_path(
path: PurePath,
) OmniUrl#

Return a new url with the path changed.

with_suffix(
suffix: str,
) OmniUrl#

Return a url with the file full suffix changed. If the url path has no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the url path.

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

omni.flux.utils.common.path_utils.cleanup_file(
file_path: OmniUrl | Path | str,
)#

Cleanup/delete a file + his metadata file

Parameters:

file_path – the file to delete/cleanup

omni.flux.utils.common.path_utils.delete_metadata(file_path: str, key: str)#

Delete a specific metadata key from a file

Parameters:
  • file_path – the file path to check (not the metadata file)

  • key – the key to delete

Returns:

None

omni.flux.utils.common.path_utils.get_absolute_path_from_relative(path: str, layer: Sdf.Layer)#

Get absolute path from a relative path. If a layer is given, it will compute the absolute path from the layer

Parameters:
  • path – the relative path

  • layer – the layer the path is relative to

Returns:

the absolute path

omni.flux.utils.common.path_utils.get_invalid_extensions(
file_paths: list[OmniUrl | Path | str],
valid_extensions: list[str],
case_sensitive: bool = False,
) list[str]#

Given a list of paths and a list of valid extensions, find and return the extensions that were not valid

Parameters:
  • file_paths – the list of file paths to check

  • valid_extensions – the list of valid file extensions

  • case_sensitive – whether the validation should be case-sensitive

Returns:

The list of invalid extensions from the paths provided with no duplicate elements

omni.flux.utils.common.path_utils.get_new_hash(
abs_in_path_str: str,
abs_out_path_str: str,
key: str = 'src_hash',
) str | None#

Get the new hash of a file. If the input file doesn’t exist, None is returned. If the current metadata file doesn’t exist, the hash is returned. If the current metadata file exists but the hash in the metadata is different than the current one, the hash is returned.

Parameters:
  • abs_in_path_str – the input file

  • abs_out_path_str – the output file

  • key – metadata key to grab

Returns:

A hash or none

omni.flux.utils.common.path_utils.get_udim_sequence(
file_path: OmniUrl | Path | str,
) list[str]#

Get the list of the textures from an UDIM path

Parameters:

file_path – the file path that contains <UDIM> or <UVTILE0> or <UVTILE1>

Returns:

The list of UDIM textures

omni.flux.utils.common.path_utils.hash_file(file_path: str, block_size: int = 8192) str | None#

Generate a hash from the data in a file.

Parameters:
  • file_path – the json file path

  • block_size – block size to read the file

Returns:

string containing the md5 hexdigest of the passed in file’s contents

omni.flux.utils.common.path_utils.hash_match_metadata(
file_path: str,
key: str = 'src_hash',
) bool | None#

Check is a hash matches the one from the metadata file

Parameters:
  • file_path – the input file to check

  • key – metadata key to grab

Returns:

True is the hash of the file match the one in the metadata

omni.flux.utils.common.path_utils.is_absolute_path(path: str) bool#

Check if the path is absolute or not

omni.flux.utils.common.path_utils.is_file_path_valid(
path: str,
layer: Sdf.Layer | None = None,
log_error: bool = True,
) bool#

Check if the relative path that depends on the layer is a valid path

Parameters:
  • path – the relative path to check

  • layer – the Sdf layer that the relative path depends on

  • log_error – show an error or not

Returns:

True if the path is valid, else False

omni.flux.utils.common.path_utils.is_udim_texture(
file_path: OmniUrl | Path | str,
) bool#

Tell if the file path is an udim texture or not

Parameters:

file_path – the file path to check

Returns:

omni.flux.utils.common.path_utils.read_file(file_path: str) bytes#

Read a file on a disk (Omniverse server or regular os disk)

Parameters:

file_path – the file path to read

Returns:

The bytes from the data that we got from the file

omni.flux.utils.common.path_utils.read_json_file(file_path: str) dict[Any, Any]#

Read a json file from Nucleus or local disk

Parameters:

file_path – the json file path to read

Returns:

The data from the json file

omni.flux.utils.common.path_utils.read_metadata(file_path: str, key: str) Any | None#

Write a metadata key for a file

Parameters:
  • file_path – the file path to read the metadata for (not the metadata file)

  • key – the key to read

Returns:

The value of the key

omni.flux.utils.common.path_utils.texture_to_udim(
file_path: OmniUrl | Path | str,
) str#

Transform an UDIM texture like toto.1001.png to the UDIM representation like toto.<UDIM>.png

Parameters:

file_path – the file path to transform

Returns:

The new name with the UDIM key

omni.flux.utils.common.path_utils.write_file(
file_path: str,
data: bytes,
raise_if_error: bool = True,
) bool#

Write a file on a disk (Omniverse server or regular os disk)

Parameters:
  • file_path – the json file path

  • data – the data to write in the json

  • raise_if_error – raise if we failed to write the file

Returns:

True is everything is fine

omni.flux.utils.common.path_utils.write_json_file(
file_path: str,
data: dict[Any, Any],
raise_if_error: bool = True,
) bool#

Write a json file on Nucleus or local disk

Parameters:
  • file_path – the json file path

  • data – the data to write in the json

  • raise_if_error – raise if we failed to write the file

Returns:

True is everything is fine

omni.flux.utils.common.path_utils.write_metadata(
file_path: str,
key: str,
value: Any,
append: bool = False,
)#

Write a metadata key for a file

Parameters:
  • file_path – the file path to write the metadata for (not the metadata file)

  • key – the key to add

  • value – the value of the metadata

  • append – whether the value should be appended to a list or overwritten if is already exists

Returns:

None

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

class omni.flux.utils.common.serialize.Converter(key: str, claim_func: ~typing.Callable[[~typing.Any], bool], serialize_hook: ~typing.Callable[[~omni.flux.utils.common.serialize.T], dict[str, Json] | list[Json] | str | int | float | bool | None | ~omni.flux.utils.common.serialize.Primitive] = <function Converter.<lambda>>, deserialize_hook: ~typing.Callable[[dict[str, Json] | list[Json] | str | int | float | bool | None | ~omni.flux.utils.common.serialize.Primitive], ~omni.flux.utils.common.serialize.T] = <function Converter.<lambda>>)#

A dataclass which holds methods used to convert data from one format to another.

class omni.flux.utils.common.serialize.Serializer#

A utility class that provides methods to serialize and deserialize objects using custom registered hooks.

Examples

There are a few ways to configure the serializer to handle custom types.

[Option 1 : Direct Converter instance] >>> import datetime … >>> serializer = Serializer() … >>> serializer.register_converter( … Converter( … key=”datetime.datetime”, … claim_func=lambda x: isinstance(x, datetime.datetime), … serialize_hook=lambda dt: dt.isoformat(), … deserialize_hook=datetime.datetime.fromisoformat, … ) … )

[Option 2 : Register serialize/deserialize hook decorators] >>> import datetime … >>> serializer = Serializer() … >>> @serializer.register_serialize_hook(datetime.datetime) >>> def serialize_datetime(dt): … return dt.isoformat() … >>> @serializer.register_deserialize_hook(datetime.datetime) >>> def deserialize_datetime(s): … return datetime.datetime.fromisoformat(s)

deserialize(
data: dict[str, Json] | list[Json] | str | int | float | bool | None,
) T#

Deserialize Json data back into native types.

dumps(
obj: T,
) dict[str, Json] | list[Json] | str | int | float | bool | None#

Wrapper for json.dumps which will serialize any complex types using the registered converters.

loads(
s: dict[str, Json] | list[Json] | str | int | float | bool | None,
) T#

Wrapper for json.loads which will deserialize into native types using the registered converters.

register_converter(
converter: Converter,
)#

Add a converter to the registry of available converters.

register_deserialize_hook(
claim_func_or_type: Type | Callable[[Any], bool],
key: str | None = None,
)#

Decorator used to register a deserialize hook for specific type(s).

register_serialize_hook(
claim_func_or_type: Type | Callable[[Any], bool],
key: str | None = None,
)#

Decorator used to register a serialize hook for specific type(s).

serialize(
obj: T,
) dict[str, Json] | list[Json] | str | int | float | bool | None#

Serialize obj to something Json friendly.

This method is called recursively for nested types such as tuple, list, set, and dict.

to_primitive(
obj: T,
) Primitive[T] | T#

Check for any registered converters for obj, if one exists, then call its serialize hook to convert it into a primitive type.

omni.flux.utils.common.serialize.register_std(serializer: Serializer)#

Simple helper method to register converters for common standard library types.

Create symlink(s). If create_junction is False and the user doesn’t have the permission to create symlink(s), it will prompt the Windows UAC for Windows user.

Parameters:
  • links_targets – list of links and targets folders to use

  • create_junction – for Windows, create a junction instead

Get a path object for path or symlink.

If the path does not exist or the symlink is broken, return None.

Check if a symlink is broken.

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

exception omni.flux.utils.common.uac.UnsupportedPlatformError#
omni.flux.utils.common.uac.is_admin() bool#

Tell if the current user has admin right or not

omni.flux.utils.common.uac.sudo(executable: str, params: list[str] | None = None)#

This will run the given executable and request to elevate administrative rights.

Parameters:
  • executable – the executable to run

  • params – list of args to run with the executable

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

omni.flux.utils.common.utils.async_wrap(func) Callable#

Wrap a function into an async executor

async omni.flux.utils.common.utils.deferred_destroy_tasks(tasks: list[Task])#

Wait for a task to be done and destroy it

Parameters:

tasks – list of async task

Returns:

omni.flux.utils.common.utils.get_omni_prims() set[Path]#

Get default reserved prims used by Omniverse Kit

Returns:

The default prims

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

omni.flux.utils.common.version.get_app_distribution() str | None#

Get the app distribution.

Example

If the app version is 1.0.0+dev.1234567890, this function will return dev.1234567890 If the app version is 1.0.0, this function will return None

omni.flux.utils.common.version.get_app_version() str#

Get the complete app version number, including the distribution.