Complete API reference for Keys & Caches experiment tracking and profiling library
kandc.init()
project
(str, optional): Project name for organizationname
(str, optional): Run name (auto-generated if not provided)config
(dict, optional): Hyperparameters and configuration to tracktags
(list, optional): Tags for filtering and organizationnotes
(str, optional): Optional description or notesdir
(str/Path, optional): Directory to save run datamode
(str, optional): Run mode - “online”, “offline”, or “disabled”reinit
(bool): Whether to reinitialize if already initializedopen_browser
(bool): Whether to open dashboard in browser (online mode)capture_code
(bool): Whether to capture code snapshotcode_exclude_patterns
(list, optional): Patterns to exclude from code captureRun
object representing the initialized experiment
Examples:
kandc.log()
data
(dict): Dictionary of metrics to logx
(float, optional): Custom x-axis value (step, epoch, time, etc.)kandc.finish()
kandc.get_current_run()
Run
object or None
if not initialized
Example:
kandc.is_initialized()
True
if initialized, False
otherwise
Example:
kandc.ProfilerWrapper
obj
: The object to wrap and profilename
(str, optional): Name for the wrapped object in logsactivities
(list, optional): Activities to profile [‘cpu’, ‘cuda’]. Defaults to both.record_shapes
(bool): Whether to record tensor shapesprofile_memory
(bool): Whether to profile memory usagewith_stack
(bool): Whether to record call stackskandc.ProfilerDecorator
kandc.profile()
kandc.profiler()
kandc.capture_model_class()
model_name
(str, optional): Name for the model traces (defaults to class name)record_shapes
(bool): Whether to record tensor shapesprofile_memory
(bool): Whether to profile memory usage**profiler_kwargs
: Additional PyTorch profiler argumentskandc.capture_model_instance()
model_instance
: The model instance to wrapmodel_name
(str, optional): Name for the model tracesrecord_shapes
(bool): Whether to record tensor shapesprofile_memory
(bool): Whether to profile memory usage**profiler_kwargs
: Additional profiler argumentskandc.capture_trace()
trace_name
(str, optional): Name for the trace (defaults to function name)record_shapes
(bool): Whether to record tensor shapesprofile_memory
(bool): Whether to profile memory usage**profiler_kwargs
: Additional profiler argumentskandc.parse_model_trace()
trace_file
(str): Path to the trace filemodel_name
(str): Name of the model for analysisNone
if parsing fails
kandc.timed()
name
(str, optional): Name for the timing record (defaults to function name)kandc.timed_call()
name
(str): Name for the timing recordfn
(callable): Function to time*args
: Positional arguments for the function**kwargs
: Keyword arguments for the functionkandc.APIClient
authenticate_with_browser()
: Browser-based authenticationcreate_project(name, description, tags, metadata)
: Create new projectcreate_run(project_name, run_data)
: Create new runlog_metrics(run_id, metrics, step)
: Log metrics to runcreate_artifact(run_id, artifact_data, file_path)
: Upload artifactget_dashboard_url(project_id, run_id)
: Get dashboard URLkandc.get_api_key()
None
if not authenticated
kandc.ensure_authenticated()
Run
object represents an active experiment run.
run.id
(str): Unique run identifierrun.name
(str): Run namerun.project
(str): Project namerun.dir
(Path): Local directory for run datarun.log(data, x)
: Log metrics to this runrun.log_artifact(path, name)
: Log artifact filerun.finish()
: Finish this runrun.get_dashboard_url()
: Get dashboard URL for this runrun.open_dashboard()
: Open dashboard in browserkandc.APIError
kandc.AuthenticationError
.gitignore
file. Add patterns there to exclude them from code capture:
.py
.js
, .ts
, .jsx
, .tsx
.java
, .cpp
, .c
, .go
, .rs
, .rb
.sh
, .bash
, .zsh
, .ps1
, .bat
.yaml
, .yml
, .json
, .toml
, .ini
.md
, .rst
, .txt
requirements.txt
, pyproject.toml
package.json
, Dockerfile
.gitignore
, .env.example
KANDC_BACKEND_URL
: Backend server URLKANDC_PROJECT
: Default project nameKANDC_MODE
: Default run mode (“online”, “offline”, “disabled”)KANDC_API_KEY
: API key for authenticationKANDC_PROFILER_DISABLED
: Disable PyTorch profiler (“1” to disable)KANDC_CAPTURE_CODE
: Enable/disable code capture (“true”, “false”)KANDC_CODE_EXCLUDE
: Comma-separated exclude patternsKANDC_MAX_FILE_SIZE
: Maximum file size in bytes for code capture