Dataset Operations¶
Source: src/memframe/main.py
OpsWrapper is the public dataset-operation interface exposed through
MemFrame. It manages uploaded datasets, tracks the active dataset, and reads
or records operation history. Each public method has an asynchronous
a-prefixed form and a synchronous form. The implementations live on
OpsMixin (src/memframe/db_manager/ops.py), which MemFrame inherits, and
the connection lifecycle lives on its ConnectorManager.
Public API¶
| Synchronous | Asynchronous | Purpose |
|---|---|---|
list_tables() |
await alist_tables() |
List successful uploads |
set_active(data_id) |
await aset_active(data_id) |
Set the active dataset (returns a ContextManager) |
get_active_table() |
await aget_active_table() |
Read the active dataset ID |
delete_table(data_id=None, filename=None) |
await adelete_table(data_id=None, filename=None) |
Delete an uploaded dataset |
list_operations(data_id=None) |
await alist_operations(data_id=None) |
List operation history |
retrieve_operation(data_id, opidx) |
await aretrieve_operation(data_id, opidx) |
Resolve an operation table name |
Dataset Management¶
List Uploaded Datasets¶
The result is ordered from newest to oldest:
[
{"data_id": "a1b2c3", "filename": "customers.csv"},
{"data_id": "d4e5f6", "filename": "orders.parquet"},
]
Only registry entries whose upload completed successfully are returned.
Select the Active Dataset¶
# set_active returns a ContextManager bound to the dataset
ctx = mf.set_active("a1b2c3")
ctx.select_dtypes(include="numeric") # operate directly on the returned context
active_id = mf.get_active_table() # still returns the active data_id string
Setting an active dataset first verifies that its upload table exists.
set_active/aset_active return a ContextManager you can use for subsequent
operations; methods that accept an optional data_id use the active dataset
when no ID is given. get_active_table() continues to return the active
data_id string.
Delete a Dataset¶
Delete by data_id:
Delete by original filename:
Deletion drops the dataset's generated transient tables, drops its upload table, removes its registry records, and clears the active dataset when necessary.
Warning
Dataset deletion is permanent.
Operation History¶
List the recorded operations for a dataset:
Each record contains opidx, operation_type, table_name, and created_at.
When no data_id is supplied, list_operations uses the active dataset.
Retrieve the generated table name for one operation:
Operation recording is handled internally by memFrame when library operations create generated tables.
Errors¶
- Operations that require a database raise
RuntimeErrorwhen not connected. - Selecting an unknown
data_idraisesDataNotFound. - Deletion requires either
data_idorfilename. - Listing operations without a supplied or active dataset raises
ValueError.
API Reference¶
memframe.main.MemFrame
¶
Bases: ContextManager, OpsMixin