rez.package_order#

class rez.package_order.PackageOrder#

Package reorderer base class.

__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.

Parameters:
  • iterable – Iterable list of packages, or objects that contain packages.

  • key (callable) – Callable, where key(iterable) gives a Package. If None, iterable is assumed to be a list of Package objects.

Returns:

List of iterable type, reordered.

class rez.package_order.NullPackageOrder#

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 a PerFamilyOrder to do this.

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.

Parameters:
  • iterable – Iterable list of packages, or objects that contain packages.

  • key (callable) – Callable, where key(iterable) gives a Package. If None, iterable is assumed to be a list of Package objects.

Returns:

List of iterable type, reordered.

to_pod()#

Example (in yaml):

type: no_order

class rez.package_order.SortedOrder#

An orderer that sorts wrt version.

__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.

Parameters:
  • iterable – Iterable list of packages, or objects that contain packages.

  • key (callable) – Callable, where key(iterable) gives a Package. If None, iterable is assumed to be a list of Package objects.

Returns:

List of iterable type, reordered.

to_pod()#

Example (in yaml):

type: sorted descending: true

class rez.package_order.PerFamilyOrder#

An orderer that applies different orderers to different package families.

__init__(order_dict, default_order=None)#

Create a reorderer.

Parameters:
  • order_dict (dict of (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.

Parameters:
  • iterable – Iterable list of packages, or objects that contain packages.

  • key (callable) – Callable, where key(iterable) gives a Package. If None, iterable is assumed to be a list of Package objects.

Returns:

List of iterable type, reordered.

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

class rez.package_order.VersionSplitPackageOrder#

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].

__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.

Parameters:
  • iterable – Iterable list of packages, or objects that contain packages.

  • key (callable) – Callable, where key(iterable) gives a Package. If None, iterable is assumed to be a list of Package objects.

Returns:

List of iterable type, reordered.

to_pod()#

Example (in yaml):

type: version_split first_version: “3.0.0”

class rez.package_order.TimestampPackageOrder#

A timestamp order function.

Given a time T, this orderer returns packages released before T, in descending order, followed by those released after. If rank 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 time T:

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).

__init__(timestamp, rank=0)#

Create a reorderer.

Parameters:
  • timestamp (int) – Epoch time of timestamp. Packages before this time are preferred.

  • rank (int) – If non-zero, allow version changes at this rank or above past the timestamp.

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.

Parameters:
  • iterable – Iterable list of packages, or objects that contain packages.

  • key (callable) – Callable, where key(iterable) gives a Package. If None, iterable is assumed to be a list of Package objects.

Returns:

List of iterable type, reordered.

to_pod()#

Example (in yaml):

type: soft_timestamp timestamp: 1234567 rank: 3

class rez.package_order.PackageOrderList#

A list of package orderer.