rez.package_order#
- class rez.package_order.FallbackComparable#
Bases:
_Comparable
First tries to compare objects using the main_comparable, but if that fails, compares using the fallback_comparable object.
- __init__(main_comparable, fallback_comparable)#
- class rez.package_order.PackageOrder#
Bases:
object
Package reorderer base class.
- name = None#
Orderer name
- __init__(packages: Iterable[str] | None = None)#
- Parameters:
packages – If not provided, PackageOrder applies to all packages.
- property packages: List[str]#
Returns an iterable over the list of package family names that this order applies to
- Returns:
(Iterable[str]) Package families that this orderer is used for
- reorder(iterable, key=None)#
Put packages into some order for consumption.
You can safely assume that the packages referred to by iterable are all versions of the same package family.
Note
Returning None, and an unchanged iterable list, are not the same thing. Returning None may cause rez to pass the package list to the next orderer; whereas a package list that has been reordered (even if the unchanged list is returned) is not passed onto another orderer.
- sort_key(package_name, version_like)#
Returns a sort key usable for sorting packages within the same family
- Parameters:
package_name – (str) The family name of the package we are sorting
version_like – (Version|_LowerBound|_UpperBound|_Bound|VersionRange|None) The version-like object to be used as a basis for generating a sort key. Note that ‘None’ is also a supported value, which maintains the default sorting order.
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- sort_key_implementation(package_name, version)#
Returns a sort key usable for sorting these packages within the same family :param package_name: (str) The family name of the package we are sorting :param version: (Version) the version object you wish to generate a key for
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- to_pod()#
- classmethod from_pod(data)#
- property sha1#
- class rez.package_order.NullPackageOrder#
Bases:
PackageOrder
An orderer that does not change the order - a no op.
This orderer is useful in cases where you want to apply some default orderer to a set of packages, but may want to explicitly NOT reorder a particular package. You would use a
NullPackageOrder
in aPerFamilyOrder
to do this.- name = 'no_order'#
Orderer name
- sort_key_implementation(package_name, version)#
Returns a sort key usable for sorting these packages within the same family :param package_name: (str) The family name of the package we are sorting :param version: (Version) the version object you wish to generate a key for
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- to_pod()#
Example (in yaml):
type: no_order packages: ["foo"]
- classmethod from_pod(data)#
- __init__(packages: Iterable[str] | None = None)#
- Parameters:
packages – If not provided, PackageOrder applies to all packages.
- property packages: List[str]#
Returns an iterable over the list of package family names that this order applies to
- Returns:
(Iterable[str]) Package families that this orderer is used for
- reorder(iterable, key=None)#
Put packages into some order for consumption.
You can safely assume that the packages referred to by iterable are all versions of the same package family.
Note
Returning None, and an unchanged iterable list, are not the same thing. Returning None may cause rez to pass the package list to the next orderer; whereas a package list that has been reordered (even if the unchanged list is returned) is not passed onto another orderer.
- property sha1#
- sort_key(package_name, version_like)#
Returns a sort key usable for sorting packages within the same family
- Parameters:
package_name – (str) The family name of the package we are sorting
version_like – (Version|_LowerBound|_UpperBound|_Bound|VersionRange|None) The version-like object to be used as a basis for generating a sort key. Note that ‘None’ is also a supported value, which maintains the default sorting order.
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- class rez.package_order.SortedOrder#
Bases:
PackageOrder
An orderer that sorts based on
Package.version
.- name = 'sorted'#
Orderer name
- __init__(descending, packages=None)#
- Parameters:
packages – If not provided, PackageOrder applies to all packages.
- sort_key_implementation(package_name, version)#
Returns a sort key usable for sorting these packages within the same family :param package_name: (str) The family name of the package we are sorting :param version: (Version) the version object you wish to generate a key for
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- to_pod()#
Example (in yaml):
type: sorted descending: true packages: ["foo"]
- classmethod from_pod(data)#
- property packages: List[str]#
Returns an iterable over the list of package family names that this order applies to
- Returns:
(Iterable[str]) Package families that this orderer is used for
- reorder(iterable, key=None)#
Put packages into some order for consumption.
You can safely assume that the packages referred to by iterable are all versions of the same package family.
Note
Returning None, and an unchanged iterable list, are not the same thing. Returning None may cause rez to pass the package list to the next orderer; whereas a package list that has been reordered (even if the unchanged list is returned) is not passed onto another orderer.
- property sha1#
- sort_key(package_name, version_like)#
Returns a sort key usable for sorting packages within the same family
- Parameters:
package_name – (str) The family name of the package we are sorting
version_like – (Version|_LowerBound|_UpperBound|_Bound|VersionRange|None) The version-like object to be used as a basis for generating a sort key. Note that ‘None’ is also a supported value, which maintains the default sorting order.
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- class rez.package_order.PerFamilyOrder#
Bases:
PackageOrder
An orderer that applies different orderers to different package families.
- name = 'per_family'#
Orderer name
- __init__(order_dict, default_order=None)#
Create a reorderer.
- Parameters:
order_dict (dict[str, PackageOrder]) – Orderers to apply to each package family.
default_order (PackageOrder) – Orderer to apply to any packages not specified in
order_dict
.
- reorder(iterable, key=None)#
Put packages into some order for consumption.
You can safely assume that the packages referred to by iterable are all versions of the same package family.
Note
Returning None, and an unchanged iterable list, are not the same thing. Returning None may cause rez to pass the package list to the next orderer; whereas a package list that has been reordered (even if the unchanged list is returned) is not passed onto another orderer.
- sort_key_implementation(package_name, version)#
Returns a sort key usable for sorting these packages within the same family :param package_name: (str) The family name of the package we are sorting :param version: (Version) the version object you wish to generate a key for
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- to_pod()#
Example (in yaml):
type: per_family orderers: - packages: ['foo', 'bah'] type: version_split first_version: '4.0.5' - packages: ['python'] type: sorted descending: false default_order: type: sorted descending: true
- classmethod from_pod(data)#
- property packages: List[str]#
Returns an iterable over the list of package family names that this order applies to
- Returns:
(Iterable[str]) Package families that this orderer is used for
- property sha1#
- sort_key(package_name, version_like)#
Returns a sort key usable for sorting packages within the same family
- Parameters:
package_name – (str) The family name of the package we are sorting
version_like – (Version|_LowerBound|_UpperBound|_Bound|VersionRange|None) The version-like object to be used as a basis for generating a sort key. Note that ‘None’ is also a supported value, which maintains the default sorting order.
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- class rez.package_order.VersionSplitPackageOrder#
Bases:
PackageOrder
Orders package versions <= a given version first.
For example, given the versions [5, 4, 3, 2, 1], an orderer initialized with
version=3
would give the order [3, 2, 1, 5, 4].- name = 'version_split'#
Orderer name
- __init__(first_version, packages=None)#
Create a reorderer.
- Parameters:
first_version (Version) – Start with versions <= this value.
- sort_key_implementation(package_name, version)#
Returns a sort key usable for sorting these packages within the same family :param package_name: (str) The family name of the package we are sorting :param version: (Version) the version object you wish to generate a key for
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- to_pod()#
Example (in yaml):
type: version_split first_version: "3.0.0" packages: ["foo"]
- classmethod from_pod(data)#
- property packages: List[str]#
Returns an iterable over the list of package family names that this order applies to
- Returns:
(Iterable[str]) Package families that this orderer is used for
- reorder(iterable, key=None)#
Put packages into some order for consumption.
You can safely assume that the packages referred to by iterable are all versions of the same package family.
Note
Returning None, and an unchanged iterable list, are not the same thing. Returning None may cause rez to pass the package list to the next orderer; whereas a package list that has been reordered (even if the unchanged list is returned) is not passed onto another orderer.
- property sha1#
- sort_key(package_name, version_like)#
Returns a sort key usable for sorting packages within the same family
- Parameters:
package_name – (str) The family name of the package we are sorting
version_like – (Version|_LowerBound|_UpperBound|_Bound|VersionRange|None) The version-like object to be used as a basis for generating a sort key. Note that ‘None’ is also a supported value, which maintains the default sorting order.
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- class rez.package_order.TimestampPackageOrder#
Bases:
PackageOrder
A timestamp order function.
Given a time
T
, this orderer returns packages released beforeT
, in descending order, followed by those released after. Ifrank
is non-zero, version changes at that rank and above are allowed over the timestamp.For example, consider the common case where we want to prioritize packages released before
T
, except for newer patches. Consider the following package versions, and timeT
:2.2.1 2.2.0 2.1.1 2.1.0 2.0.6 2.0.5 <-- T 2.0.0 1.9.0
A timestamp orderer set to
rank=3
(patch versions) will attempt to consume the packages in the following order:2.0.6 2.0.5 2.0.0 1.9.0 2.1.1 2.1.0 2.2.1 2.2.0
Notice that packages before
T
are preferred, followed by newer versions. Newer versions are consumed in ascending order, except within rank (this is why 2.1.1 is consumed before 2.1.0).- name = 'soft_timestamp'#
Orderer name
- __init__(timestamp, rank=0, packages=None)#
Create a reorderer.
- sort_key_implementation(package_name, version)#
Returns a sort key usable for sorting these packages within the same family :param package_name: (str) The family name of the package we are sorting :param version: (Version) the version object you wish to generate a key for
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- to_pod()#
Example (in yaml):
type: soft_timestamp timestamp: 1234567 rank: 3 packages: ["foo"]
- classmethod from_pod(data)#
- property packages: List[str]#
Returns an iterable over the list of package family names that this order applies to
- Returns:
(Iterable[str]) Package families that this orderer is used for
- reorder(iterable, key=None)#
Put packages into some order for consumption.
You can safely assume that the packages referred to by iterable are all versions of the same package family.
Note
Returning None, and an unchanged iterable list, are not the same thing. Returning None may cause rez to pass the package list to the next orderer; whereas a package list that has been reordered (even if the unchanged list is returned) is not passed onto another orderer.
- property sha1#
- sort_key(package_name, version_like)#
Returns a sort key usable for sorting packages within the same family
- Parameters:
package_name – (str) The family name of the package we are sorting
version_like – (Version|_LowerBound|_UpperBound|_Bound|VersionRange|None) The version-like object to be used as a basis for generating a sort key. Note that ‘None’ is also a supported value, which maintains the default sorting order.
- Returns:
- Sortable object
The returned object must be sortable, which means that it must implement __lt__. The specific return type is not important.
- class rez.package_order.PackageOrderList#
Bases:
list
A list of package orderer.
- __init__(*args, **kwargs)#
- to_pod()#
- classmethod from_pod(data)#
- singleton = []#
- append(*args, **kwargs)#
Append object to the end of the list.
- extend(*args, **kwargs)#
Extend list by appending elements from the iterable.
- pop(*args, **kwargs)#
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(*args, **kwargs)#
Remove first occurrence of value.
Raises ValueError if the value is not present.
- clear(*args, **kwargs)#
Remove all items from list.
- insert(*args, **kwargs)#
Insert object before index.
- get(key: str, default: PackageOrder | None = None) PackageOrder #
Get an orderer that sorts a package by name.
- __new__(**kwargs)#
- copy()#
Return a shallow copy of the list.
- count(value, /)#
Return number of occurrences of value.
- index(value, start=0, stop=9223372036854775807, /)#
Return first index of value.
Raises ValueError if the value is not present.
- reverse()#
Reverse IN PLACE.
- sort(*, key=None, reverse=False)#
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
- rez.package_order.to_pod(orderer)#
- rez.package_order.from_pod(data)#
- rez.package_order.get_orderer(package_name, orderers=None)#
- rez.package_order.register_orderer(cls)#
Register an orderer
- Parameters:
cls (type[PackageOrder]) – Package orderer class to register.
- Returns:
True if successfully registered, else False.
- Return type: