Skip to content

File resource

FileResource

FileResource(path)

Bases: Resource

Wrap columnar data and its metadata in a local file.

Vectice stores metadata -- data about your dataset -- communicated with a resource. Your actual dataset is not stored by Vectice.

This resource wraps data that you have stored in a local file.

from vectice import FileResource, connect

my_project = connect(...)  # (1)
my_phase = my_project.phase(...)  # (2)
my_iter = my_phase.iteration()  # (3)

my_iter.step_my_data = FileResource(path="my/file/path")
  1. See connection.
  2. See phases.
  3. See iterations.

Note that these three concepts are distinct, even if easily conflated:

  • Where the data is stored
  • The format at rest (in storage)
  • The format when loaded in a running Python program

Notably, the statistics collectors provided by Vectice operate only on this last and only in the event that the data is loaded as a pandas dataframe.

Parameters:

Name Type Description Default
path str

The path of the file to wrap.

required

Examples:

The following example shows how to wrap a CSV file called iris.csv in the current directory:

from vectice import FileResource
iris_trainset = FileResource(path="iris.csv")
Source code in src/vectice/models/resource/file_resource.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def __init__(self, path: str):
    """Initialize a file resource.

    Parameters:
        path: The path of the file to wrap.

    Examples:
        The following example shows how to wrap a CSV file
        called `iris.csv` in the current directory:

        ```python
        from vectice import FileResource
        iris_trainset = FileResource(path="iris.csv")
        ```
    """
    super().__init__()
    self.path = path
    _logger.info(f"File: {path} wrapped successfully.")