Skip to content

Evidence

Introduction

evidence.upload is part of the Modulos SDK and is used to upload artifacts as evidence to the Modulos platform. This provides methods to upload both local files and various data types as evidence, which can be associated with specific projects and components.

Usage

Initialization

First, initialize the Modulos client

python
from modulos import Modulos
modulos = Modulos()

Uploading a Local File

Use the artifact_file method to upload a file from your local system:

python
modulos.evidence.upload.artifact_file(
    path_to_file="path/to/your/file.txt",
    project_id="your_project_id",
    component_id="your_component_id",
    file_name="optional_custom_filename.txt",
    description="Optional description of the file"
)

Parameters:

  • path_to_file (str): The path to the local file you want to upload.
  • project_id (str): The ID of the project to associate the evidence with.
  • component_id (str): The ID of the component to associate the evidence with.
  • file_name (str, optional): A custom name for the file. If not provided, the original filename will be used.
  • description (str, optional): A description of the file.

Uploading Data as a File

Use the artifact_result method to upload various data types (pandas DataFrame, dictionary, or other objects) as a file:

python
import pandas as pd

#Example with a pandas DataFrame
df = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'c']})

modulos.evidence.upload.artifact_result(
    result=df,
    file_name="data.csv",
    project_id="your_project_id",
    component_id="your_component_id",
    description="Sample DataFrame as CSV"
)

#Example with a dictionary
data_dict = {'key1': 'value1', 'key2': 'value2'}

modulos.evidence.upload.artifact_result(
    result=data_dict,
    file_name="data.json",
    project_id="your_project_id",
    component_id="your_component_id",
    description="Sample dictionary as JSON"
)

Parameters:

  • result (pd.DataFrame | Dict[str, Any] | Any): The data to be uploaded.
  • file_name (str): The name of the file to be created, including the extension (e.g., .csv, .json, .txt, .pkl).
  • project_id (str): The ID of the project to associate the evidence with.
  • component_id (str): The ID of the component to associate the evidence with.
  • description (str, optional): A description of the file.

Supported File Types:

  • CSV (.csv): For pandas DataFrames or dictionaries
  • JSON (.json): For dictionaries or pandas DataFrames
  • Text (.txt): For string data
  • Pickle (.pkl): For any Python object that can be pickled

Best Practices

  1. Always ensure you have the correct project_id and component_id before uploading.
  2. Use descriptive file names and add descriptions to make it easier to identify evidence later.
  3. For large files or datasets, consider using artifact_file with a pre-saved file to avoid memory issues.
  4. When using artifact_result, choose the appropriate file extension based on your data type to ensure proper handling.

Conclusion

modulos.evidence.uploadprovides a straightforward way to add evidence to your Modulos projects. By using these methods, you can easily upload files and data to substantiate claims, actions, or compliance within your AI governance process.