Skip to content

File Limit (legacy)

Bases: BaseFileLimit, FrozenModel

Limits the number of downloaded files.

.. deprecated:: 0.8.0

Use :obj:`MaxFilesCount <onetl.file.limit.max_files_count.MaxFilesCount>` instead.

Parameters:

  • count_limit (int, default: = 100 ) –

    Number of downloaded files at a time.

Examples:

Create a FileLimit object and set the amount in it:

.. code:: python

from onetl.core import FileLimit

limit = FileLimit(count_limit=1500)

If you create a :obj:onetl.file.file_downloader.file_downloader.FileDownloader object without specifying the limit option, it will download with a limit of 100 files.

is_reached property

Check if limit is reached.

.. versionadded:: 0.8.0

Returns:

  • ``True`` if limit is reached, ``False`` otherwise.

Examples:

>>> from onetl.impl import LocalPath
>>> limit.is_reached
False
>>> limit.stops_at(LocalPath("/path/to/file.csv"))
False
>>> limit.is_reached
False
>>> # after limit is reached
>>> limit.stops_at(LocalPath("/path/to/file.csv"))
True
>>> limit.is_reached
True

reset()

Resets the internal limit state.

.. versionadded:: 0.8.0

Returns:

  • Returns a filter of the same type, but with non-reached state.
  • It could be the same filter or a new one, this is an implementation detail.

Examples:

>>> limit.is_reached
True
>>> new_limit = limit.reset()
>>> new_limit.is_reached
False

stops_at(path)

Update internal state and return current state.

.. versionadded:: 0.8.0

Parameters:

  • path (:obj:onetl.base.path_protocol.PathProtocol) –

    Path to check

Returns:

  • ``True`` if limit is reached, ``False`` otherwise.

Examples:

>>> from onetl.impl import LocalPath
>>> # limit is not reached yet
>>> limit.stops_at(LocalPath("/path/to/file.csv"))
False
>>> # after limit is reached
>>> limit.stops_at(LocalPath("/path/to/another.csv"))
True
>>> # at this point, .stops_at() and .is_reached will always return True,
>>> # even on inputs that returned False before.
>>> # it will be in the same state until .reset() is called
>>> limit.stops_at(LocalPath("/path/to/file.csv"))
True