idmtools.utils.filters.asset_filters module#

This module contains all the default filters for the assets.

A filter function needs to take only one argument: an asset. It returns True/False indicating whether to add or filter out the asset.

You can notice functions taking more than only an asset. To use those functions, use must create a partial before adding it to a filters list. For example:

python
fname = partial(file_name_is, filenames=["a.txt", "b.txt"])
AssetCollection.from_directory(... filters=[fname], ...)
idmtools.utils.filters.asset_filters.default_asset_file_filter(asset: TAsset) bool[source]#

Default filter to leave out Python caching.

This filter is used in the creation of AssetCollection, regardless of user filters.

Returns:

True if no files match default patterns of “__py_cache__” and “.pyc”

idmtools.utils.filters.asset_filters.file_name_is(asset: TAsset, filenames: List[str]) bool[source]#

Restrict filtering to assets with the indicated filenames.

Parameters:
  • asset – The asset to filter.

  • filenames – List of filenames to filter on.

Returns:

True if asset.filename in filenames

idmtools.utils.filters.asset_filters.file_extension_is(asset: TAsset, extensions: List[str]) bool[source]#

Restrict filtering to assets with the indicated filetypes.

Parameters:
  • asset – The asset to filter.

  • extensions – List of extensions to filter on.

Returns:

True if extension in extensions

idmtools.utils.filters.asset_filters.asset_in_directory(asset: TAsset, directories: List[str], base_path: str = None) bool[source]#

Restrict filtering to assets within a given directory.

This filter is not strict and simply checks if the directory portion is present in the assets absolute path.

Parameters:
  • asset – The asset to filter.

  • directories – List of directory portions to include.

  • base_path – base_path