rez.package_order#
- class rez.package_order.PackageOrder#
Bases:
object
Package reorderer base class.
- name = None#
Orderer name
- __init__()#
- 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.
- to_pod()#
- 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
- 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.
- to_pod()#
Example (in yaml):
type: no_order
- classmethod from_pod(data)#
- __init__()#
- property sha1#
- class rez.package_order.SortedOrder#
Bases:
PackageOrder
An orderer that sorts based on
Package.version
.- name = 'sorted'#
Orderer name
- __init__(descending)#
- 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.
- to_pod()#
Example (in yaml):
type: sorted descending: true
- classmethod from_pod(data)#
- property sha1#
- 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.
- 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 sha1#
- 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)#
Create a reorderer.
- Parameters:
first_version (Version) – Start with versions <= this value.
- 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.
- to_pod()#
Example (in yaml):
type: version_split first_version: "3.0.0"
- classmethod from_pod(data)#
- property sha1#
- 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)#
Create a reorderer.
- 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.
- to_pod()#
Example (in yaml):
type: soft_timestamp timestamp: 1234567 rank: 3
- classmethod from_pod(data)#
- property sha1#
- class rez.package_order.PackageOrderList#
Bases:
list
A list of package orderer.
- to_pod()#
- classmethod from_pod(data)#
- singleton = []#
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- append(object, /)#
Append object to the end of the list.
- clear()#
Remove all items from list.
- copy()#
Return a shallow copy of the list.
- count(value, /)#
Return number of occurrences of value.
- extend(iterable, /)#
Extend list by appending elements from the iterable.
- index(value, start=0, stop=9223372036854775807, /)#
Return first index of value.
Raises ValueError if the value is not present.
- insert(index, object, /)#
Insert object before index.
- pop(index=-1, /)#
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)#
Remove first occurrence 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.register_orderer(cls)#
Register an orderer
- Parameters:
cls (type[PackageOrder]) – Package orderer class to register.
- Returns:
True if successfully registered, else False.
- Return type: