This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Operations

Functions and operations for querying and manipulating W&B data in the Query Expression Language.

Available Operations

1 - Artifact Operations

Operations for querying and manipulating W&B artifacts

artifactLink(artifact): string

Gets the URL/link for accessing an artifact in the W&B UI.

Returns a direct link to view the artifact in the W&B web interface, useful for generating reports or sharing artifact references.

Parameters

Name Type Description
artifact Artifact The artifact to get the link for
const link = artifactLink(myArtifact);
console.log(View artifact: ${link});
// Output: https://wandb.ai/entity/project/artifacts/type/name
const artifacts = project.artifacts();
const markdown = artifacts.map(a => 
  - ${artifactName(a)}})
).join('\n');

See Also


artifactName

artifactName(artifact): string

Gets the name of an artifact.

Returns the artifact’s unique name within its project.

Parameters

Name Type Description
artifact Artifact The artifact to get the name from

Example: Display Artifact Names

artifacts.forEach(artifact => {
  console.log(Artifact: ${artifactName(artifact)});
});

Example: Filter by Name Pattern

const modelArtifacts = artifacts.filter(a => 
  artifactName(a).includes("model")
);

See Also


artifactVersionAlias

artifactVersionAlias(version): string

Gets the alias of an artifact version.

Returns the version alias (e.g., “latest”, “best”, “production”).

Parameters

Name Type Description
version ArtifactVersion The artifact version

Example: Find Production Version

const prodVersion = versions.find(v => 
  artifactVersionAlias(v) === "production"
);

See Also

artifactVersions - Get all versions


artifactVersionCreatedAt

artifactVersionCreatedAt(version): Date

Gets the creation date of an artifact version.

Returns when a specific version of the artifact was created.

Parameters

Name Type Description
version ArtifactVersion The artifact version to get creation date from

Example: Sort Versions by Date

const sorted = versions.sort((a, b) => 
  artifactVersionCreatedAt(a).getTime() - 
  artifactVersionCreatedAt(b).getTime()
);

See Also

artifactVersions - Get all versions


artifactVersionDigest

artifactVersionDigest(version): string

Gets the content digest/hash of an artifact version.

Returns the SHA256 digest used to verify artifact integrity.

Parameters

Name Type Description
version ArtifactVersion The artifact version

Example: Verify Artifact Integrity

const digest = artifactVersionDigest(version);
const expected = "sha256:abc123...";
if (digest !== expected) {
  console.error("Artifact integrity check failed!");
}

See Also

artifactVersions - Get all versions


artifactVersionNumber

artifactVersionNumber(version): number

Gets the version number of an artifact version.

Returns the numeric version identifier.

Parameters

Name Type Description
version ArtifactVersion The artifact version

Example: Get Latest Version Number

const versions = artifactVersions(artifact);
const maxVersion = Math.max(...versions.map(v => 
  artifactVersionNumber(v)
));
console.log(Latest version: v${maxVersion});

See Also

artifactVersions - Get all versions


artifactVersionSize

artifactVersionSize(version): number

Gets the size of an artifact version in bytes.

Returns the storage size of a specific artifact version.

Parameters

Name Type Description
version ArtifactVersion The artifact version to get size from

Example: Display Human-Readable Size

const bytes = artifactVersionSize(version);
const mb = (bytes / 1e6).toFixed(2);
console.log(Size: ${mb} MB);

Example: Find Large Artifacts

const largeVersions = versions.filter(v => 
  artifactVersionSize(v) > 1e9 // > 1GB
);

See Also

artifactVersions - Get all versions


artifactVersions

artifactVersions(artifact): ArtifactVersion[]

Gets all versions of an artifact.

Returns an array of all version objects for the artifact, including version numbers, aliases, sizes, and timestamps.

Parameters

Name Type Description
artifact Artifact The artifact to get versions from

Example: List All Versions

const versions = artifactVersions(myArtifact);
versions.forEach(v => {
  console.log(v${v.version}: ${v.alias} (${v.size} bytes));
});

Example: Find Latest Version

const versions = artifactVersions(artifact);
const latest = versions.find(v => v.alias === "latest");
if (latest) {
  console.log(Latest is v${latest.version});
}

Example: Calculate Total Storage

const versions = artifactVersions(artifact);
const totalSize = versions.reduce((sum, v) => sum + v.size, 0);
console.log(Total storage: ${(totalSize / 1e9).toFixed(2)} GB);

See Also

2 - Run Operations

Operations for querying and manipulating W&B runs

runConfig

runConfig(run): ConfigDict

Extracts the configuration dictionary (ConfigDict) from a W&B run.

The configuration contains hyperparameters and settings used when the run was initialized. This is particularly useful for comparing configurations across experiments or filtering runs based on specific parameter values.

Parameters

Name Type Description
run Run The W&B run object to extract configuration from

Example: Basic Configuration Access

const config = runConfig(myRun);
console.log(config.learning_rate); // 0.001
console.log(config.batch_size);    // 32

Example: Filtering Runs by Configuration

// Find all runs with learning rate > 0.01
const highLRRuns = runs.filter(run => {
  const config = runConfig(run);
  return config.learning_rate > 0.01;
});

Example: Comparing Configurations

const config1 = runConfig(baseline);
const config2 = runConfig(experiment);
const differences = Object.keys(config1).filter(key => 
  config1[key] !== config2[key]
);

See Also

  • runSummary - For accessing summary metrics
  • runHistory - For accessing time-series data

runCreatedAt

runCreatedAt(run): Date

Gets the creation timestamp of a W&B run.

Returns when the run was first initialized. Useful for chronological sorting, filtering by date ranges, or analyzing experiment progression over time.

Parameters

Name Type Description
run Run The W&B run to get creation time from

Example: Filter Recent Runs

const oneWeekAgo = new Date();
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);

const recentRuns = runs.filter(run => 
  runCreatedAt(run) > oneWeekAgo
);

Example: Sort Chronologically

const sortedRuns = runs.sort((a, b) => 
  runCreatedAt(a).getTime() - runCreatedAt(b).getTime()
);

Example: Group by Date

const runsByDate = runs.reduce((groups, run) => {
  const date = runCreatedAt(run).toDateString();
  groups[date] = groups[date] || [];
  groups[date].push(run);
  return groups;
}, {});

See Also


runHeartbeatAt

runHeartbeatAt(run): Date

Gets the last heartbeat timestamp of a W&B run.

The heartbeat indicates when the run last sent data to W&B. For active runs, this is continuously updated. For finished runs, it shows the completion time.

Parameters

Name Type Description
run Run The W&B run to get heartbeat from

Example: Check if Run is Active

const isActive = (run: Run) => {
  const lastHeartbeat = runHeartbeatAt(run);
  const fiveMinutesAgo = new Date(Date.now() - 5 * 60 * 1000);
  return lastHeartbeat > fiveMinutesAgo;
};

See Also


runJobType

runJobType(run): string | undefined

Gets the job type of a run.

Returns the job type classification (e.g., “train”, “eval”, “sweep”) if set.

Parameters

Name Type Description
run Run The W&B run to get job type from

Example: Filter by Job Type

const trainingRuns = runs.filter(run => 
  runJobType(run) === "train"
);
const evalRuns = runs.filter(run => 
  runJobType(run) === "eval"
);

See Also

Run - Run type definition


runLoggedArtifactVersion

runLoggedArtifactVersion(run, artifactVersionName): ArtifactVersion | undefined

Gets a specific artifact version logged (output) by a run.

Artifacts in W&B are versioned files or directories that track model checkpoints, datasets, or other outputs. This function retrieves a specific artifact version that was created/logged during the run’s execution.

Parameters

Name Type Description
run Run The W&B run that logged the artifact
artifactVersionName string Artifact identifier as “name:alias” (e.g., “model:latest”, “dataset:v2”)

Example: Get Latest Model

const model = runLoggedArtifactVersion(run, "model:latest");
if (model) {
  console.log(Model version: v${model.version});
  console.log(Model size: ${model.size} bytes);
  console.log(Created: ${model.createdAt});
}

Example: Verify Output Artifacts

const requiredOutputs = ["model:latest", "evaluation:latest"];
const missing = requiredOutputs.filter(name => 
  !runLoggedArtifactVersion(run, name)
);
if (missing.length > 0) {
  console.warn(Missing outputs: ${missing.join(", ")});
}

See Also


runLoggedArtifactVersions

runLoggedArtifactVersions(run): ArtifactVersion[]

Gets all artifact versions logged (output) by a run.

Returns a complete list of all artifacts created during the run’s execution, including models, datasets, checkpoints, and other outputs.

Parameters

Name Type Description
run Run The W&B run to get logged artifacts from

Example: List All Outputs

const outputs = runLoggedArtifactVersions(run);
outputs.forEach(artifact => {
  console.log(Logged: ${artifact.name}:${artifact.alias});
  console.log(  Version: ${artifact.version});
  console.log(  Size: ${artifact.size} bytes);
});

Example: Count Output Types

const outputs = runLoggedArtifactVersions(run);
const modelCount = outputs.filter(a => a.name.includes("model")).length;
const dataCount = outputs.filter(a => a.name.includes("data")).length;
console.log(Models: ${modelCount}, Datasets: ${dataCount});

See Also


runName

runName(run): string

Gets the name/ID of a run.

Returns the unique run name (ID) assigned by W&B or set by the user.

Parameters

Name Type Description
run Run The W&B run to get name from

Example: Display Run Names

runs.forEach(run => {
  console.log(Run: ${runName(run)});
});

See Also

Run - Run type definition


runRuntime

runRuntime(run): number

Calculates the runtime duration of a W&B run in seconds.

Returns the total execution time from creation to last heartbeat. For active runs, this represents the current runtime.

Parameters

Name Type Description
run Run The W&B run to calculate runtime for

Example: Display Runtime

const runtime = runRuntime(myRun);
const hours = Math.floor(runtime / 3600);
const minutes = Math.floor((runtime % 3600) / 60);
console.log(Runtime: ${hours}h ${minutes}m);

Example: Filter Long-Running Experiments

const longRuns = runs.filter(run => 
  runRuntime(run) > 3600 // More than 1 hour
);

See Also


runSummary

runSummary(run): SummaryDict

Retrieves summary metrics (SummaryDict) from a W&B run.

Summary metrics represent the final or best values logged during a run’s execution, such as final accuracy, best validation loss, or total training time. These are scalar values that summarize the run’s overall performance.

Parameters

Name Type Description
run Run The W&B run to extract summary from

Example: Accessing Final Metrics

const summary = runSummary(myRun);
console.log(Final accuracy: ${summary.accuracy});
console.log(Best validation loss: ${summary.best_val_loss});
console.log(Training time: ${summary.training_time_seconds});

Example: Finding Best Performing Run

const bestRun = runs.reduce((best, current) => {
  const bestSummary = runSummary(best);
  const currentSummary = runSummary(current);
  return currentSummary.accuracy > bestSummary.accuracy ? current : best;
});

Example: Filtering by Performance Threshold

const goodRuns = runs.filter(run => {
  const summary = runSummary(run);
  return summary.accuracy > 0.95 && summary.val_loss < 0.1;
});

See Also

  • runConfig - For configuration parameters
  • runHistory - For time-series metrics

runUsedArtifactVersions

runUsedArtifactVersions(run): ArtifactVersion[]

Gets all artifact versions used (input) by a run.

Returns artifacts that were consumed as inputs during the run’s execution, such as training datasets, pretrained models, or configuration files.

Parameters

Name Type Description
run Run The W&B run to get used artifacts from

Example: List Input Dependencies

const inputs = runUsedArtifactVersions(run);
console.log("Run dependencies:");
inputs.forEach(artifact => {
  console.log(- ${artifact.name}:${artifact.version});
});

Example: Verify Dataset Version

const inputs = runUsedArtifactVersions(run);
const dataset = inputs.find(a => a.name === "training-data");
if (dataset && dataset.version !== 3) {
  console.warn(Using outdated dataset v${dataset.version});
}

See Also


runUser

runUser(run): User

Gets the user who created the run.

Returns the W&B user object associated with the run, useful for filtering by user or analyzing team member contributions.

Parameters

Name Type Description
run Run The W&B run to get user from

Example: Filter by User

const myRuns = runs.filter(run => 
  runUser(run).username === "john_doe"
);

Example: Group Runs by User

const runsByUser = runs.reduce((groups, run) => {
  const user = runUser(run).username;
  groups[user] = groups[user] || [];
  groups[user].push(run);
  return groups;
}, {});

See Also

User - User type definition