repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
microsoft/causica | import math
import pytest
import torch
from tensordict import TensorDict
from causica.functional_relationships import (
DECIEmbedFunctionalRelationships,
LinearFunctionalRelationships,
RFFFunctionalRelationships,
)
def fixture_two_variable_dict():
return {"x1": torch.Size([1]), "x2": torch.Size([2])}... | (3, 2, 2) | assert | collection | test/functional_relationships/test_functional_relationships.py | test_func_rel_forward_multigraph | 58 | null | |
microsoft/causica | import networkx as nx
import torch
from causica.distributions import ErdosRenyiDAGDistribution
def test_num_deges():
num_edges = 16
samples = ErdosRenyiDAGDistribution(num_nodes=8, num_edges=torch.tensor(num_edges)).sample(torch.Size([100]))
assert samples.shape == torch.Size([100, 8, 8])
torch.test... | torch.tensor(num_edges, dtype=torch.float32)) | assert_* | func_call | test/distributions/adjacency/test_erdos_renyi.py | test_num_deges | 48 | null | |
microsoft/causica | import logging
from typing import Any, Optional, Sequence
import numpy as np
import pytorch_lightning as pl
import torch
from data_module import ExampleDataModule
from pytorch_lightning.callbacks import LearningRateMonitor
from tensordict import TensorDict
from torchmetrics import MetricCollection
from torchmetrics.cl... | None | assert | none_literal | examples/lightning_example/lightning_module.py | setup | ExampleDECIModule | 53 | null |
microsoft/causica | from typing import Optional, Type, Union
import numpy as np
import pytest
import torch
from causica.distributions.adjacency import (
AdjacencyDistribution,
ConstrainedAdjacencyDistribution,
ENCOAdjacencyDistribution,
TemporalConstrainedAdjacencyDistribution,
ThreeWayAdjacencyDistribution,
)
from c... | sample_shape + batch_shape | assert | complex_expr | test/distributions/adjacency/test_adjacency_distributions.py | test_log_prob | 422 | null | |
microsoft/causica | import numpy as np
import pytest
import torch
from torch.distributions.utils import probs_to_logits
from causica.distributions.adjacency.enco import ENCOAdjacencyDistribution
from causica.distributions.adjacency.temporal_adjacency_distributions import (
RhinoLaggedAdjacencyDistribution,
TemporalAdjacencyDistri... | logits_exist_np[1, 0] | assert | complex_expr | test/distributions/adjacency/test_enco.py | test_enco_backprop | 91 | null | |
microsoft/causica | import pytest
import torch
from tensordict import TensorDict
from causica.functional_relationships import LinearFunctionalRelationships, create_do_functional_relationship
def fixture_two_variable_dict():
return {"x1": torch.Size([1]), "x2": torch.Size([2])}
def fixture_three_variable_dict():
return {"x1": to... | (100, 2, 1) | assert | collection | test/functional_relationships/test_do_functional_relationships.py | test_do_linear_graph_stack | 26 | null | |
microsoft/causica | import pytest
import torch
from causica.nn import DECIEmbedNN
PROCESSED_DIM = 6
NODE_NUM = 4
GROUP_MASK = torch.tensor(
[
[1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 1, 1],
],
dtype=torch.float32,
)
GRAPH_SHAPES = [tuple(), (5,), (2, 3)]
SAMPLE... | sample_shape + graph_shape + (PROCESSED_DIM,) | assert | func_call | test/nn/test_deci_embed_nn.py | test_fgnni_broadcast | 32 | null | |
microsoft/causica | import networkx as nx
import torch
from causica.distributions import WattsStrogatzDAGDistribution
def test_samples_dags():
"""Test that all samples are DAGs"""
n = 5
lattice_dim = [2, 3]
rewire_prob = [0.1, 0.3]
neighbors = [1, 3]
sample_shape = torch.Size([3, 4])
dist = WattsStrogatzDAGDi... | torch.Size(sample_shape + (n, n)) | assert | func_call | test/distributions/adjacency/test_watts_strogatz.py | test_samples_dags | 18 | null | |
microsoft/causica | import logging
from dataclasses import asdict, is_dataclass
from typing import Any, Mapping, Optional, Sequence, Union
import fsspec
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.utilities.types import STEP_OUTPUT
from tensordict import TensorDict
from causica.datasets.causica_... | None | assert | none_literal | src/causica/lightning/modules/deci_module.py | setup | DECIModule | 169 | null |
microsoft/causica | import json
import numpy as np
import pandas as pd
import pytest
import torch
from pytorch_lightning.trainer import Trainer
from tensordict import TensorDict
from causica.datasets.causica_dataset_format import Variable, VariablesMetadata
from causica.lightning.data_modules.variable_spec_data import VariableSpecDataMo... | load_param) | assert_* | variable | test/lightning/test_variable_spec_data.py | test_save_load_variable_spec_data | 255 | null | |
microsoft/causica | import logging
from typing import Any, Optional, Sequence
import numpy as np
import pytorch_lightning as pl
import torch
from data_module import ExampleDataModule
from pytorch_lightning.callbacks import LearningRateMonitor
from tensordict import TensorDict
from torchmetrics import MetricCollection
from torchmetrics.cl... | 0 | assert | numeric_literal | examples/lightning_example/lightning_module.py | observational_evaluation_step | ExampleDECIModule | 148 | null |
microsoft/causica | import pytest
import torch
from tensordict import TensorDict
from causica.distributions import (
BernoulliNoise,
CategoricalNoise,
IndependentNoise,
JointNoise,
Noise,
UnivariateNormalNoise,
)
torch.manual_seed(0)
NOISE_DISTRIBUTIONS = [
IndependentNoise(BernoulliNoise(torch.randn(3), tor... | noise.mode) | assert_* | complex_expr | test/distributions/noise/test_joint.py | test_joint_noise_passthrough | 33 | null | |
microsoft/causica | import os
import tempfile
import numpy as np
import pytest
import torch
import torch.distributions as td
from tensordict import TensorDict
from causica.data_generation.generate_data import (
generate_sem_sampler,
get_variable_definitions,
plot_dataset,
sample_counterfactual,
sample_dataset,
sa... | observations) | assert_* | variable | test/data_generation/test_generate_data.py | test_sample_counterfactuals | 135 | null | |
microsoft/causica | import pytest
import torch
from causica.triangular_transformations import fill_triangular, unfill_triangular
DIM = 5
@pytest.mark.parametrize("batch_size", [tuple(), (3,), (4, 2)])
def test_fill_unfill(batch_size):
"""Test that filling and unfilling results in the same tensor"""
matrix = torch.randn(batch_si... | fill_triangular(lower_vec, upper=True)) | assert_* | func_call | test/test_triangular_transformations.py | test_fill_unfill | 18 | null | |
microsoft/causica | import pytest
import torch
from tensordict import TensorDict
from causica.distributions import (
BernoulliNoise,
CategoricalNoise,
IndependentNoise,
JointNoise,
Noise,
UnivariateNormalNoise,
)
torch.manual_seed(0)
NOISE_DISTRIBUTIONS = [
IndependentNoise(BernoulliNoise(torch.randn(3), tor... | noise.entropy()) | assert_* | func_call | test/distributions/noise/test_joint.py | test_joint_noise_passthrough | 32 | null | |
microsoft/causica | import os
import tempfile
import pytest
import torch
from causica.datasets.causica_dataset_format import CAUSICA_DATASETS_PATH, DataEnum, load_data, save_data, save_dataset
from causica.datasets.tensordict_utils import tensordict_shapes
def _load_and_test_dataset(root_path: str):
variables_metadata = load_data(r... | int_groups_a | assert | variable | test/integration/test_save_load_csuite.py | _load_and_test_dataset | 22 | null | |
microsoft/causica | import pytest
import torch
from tensordict import TensorDict
from causica.distributions import (
BernoulliNoise,
CategoricalNoise,
IndependentNoise,
JointNoise,
Noise,
UnivariateNormalNoise,
)
torch.manual_seed(0)
NOISE_DISTRIBUTIONS = [
IndependentNoise(BernoulliNoise(torch.randn(3), tor... | joint_log_probs.shape | assert | complex_expr | test/distributions/noise/test_joint.py | test_joint_noise_empirical | 88 | null | |
microsoft/causica | import pytest
import torch
from causica.distributions.adjacency.adjacency_distributions import AdjacencyDistribution
from causica.distributions.adjacency.enco import ENCOAdjacencyDistribution
from causica.distributions.noise.joint import JointNoiseModule
from causica.distributions.noise.noise import Noise, NoiseModule... | sem_dist.mode.graph) | assert_* | complex_expr | test/distributions/test_sem_distribution.py | test_sem_distribution_passthrough | 46 | null | |
microsoft/causica | import math
import pytest
import torch
import torch.distributions as td
from causica.distributions.noise import BernoulliNoise
def sample_logistic_noise(n_samples, input_dim, base_logits):
"""
Samples a Logistic random variable that can be used to sample this variable.
This method does **not** return har... | torch.Size([2, 3]) | assert | func_call | test/distributions/noise/test_bernoulli.py | test_init | 41 | null | |
microsoft/causica | from typing import Type
import pytest
import torch
from causica.distributions.adjacency.adjacency_distributions import AdjacencyDistribution
from causica.distributions.adjacency.constrained_adjacency_distributions import constrained_adjacency
from causica.distributions.adjacency.enco import ENCOAdjacencyDistribution
... | 1 | assert | numeric_literal | test/distributions/adjacency/test_constrained_adjacency_distributions.py | test_temporal_constrained_adjacency | 91 | null | |
microsoft/causica | import io
import itertools
from typing import Any, TypeVar
import pytest
import torch
from tensordict import TensorDictBase, make_tensordict
from causica.distributions.transforms import SequentialTransformModule
from causica.distributions.transforms.base import TransformModule
from causica.distributions.transforms.jo... | transform | assert | variable | test/distributions/transforms/test_transform_modules.py | test_transform_module_output | 55 | null | |
microsoft/causica | import logging
from typing import Any, Optional, Sequence
import numpy as np
import pytorch_lightning as pl
import torch
from data_module import ExampleDataModule
from pytorch_lightning.callbacks import LearningRateMonitor
from tensordict import TensorDict
from torchmetrics import MetricCollection
from torchmetrics.cl... | 1 | assert | numeric_literal | examples/lightning_example/lightning_module.py | observational_evaluation_step | ExampleDECIModule | 153 | null |
microsoft/causica | import os
import tempfile
import numpy as np
import pytest
import torch
import torch.distributions as td
from tensordict import TensorDict
from causica.data_generation.generate_data import (
generate_sem_sampler,
get_variable_definitions,
plot_dataset,
sample_counterfactual,
sample_dataset,
sa... | five_node_graph) | assert_* | variable | test/data_generation/test_generate_data.py | test_generate_sem_numpy | 206 | null | |
microsoft/causica | import networkx as nx
import torch
from causica.distributions import ErdosRenyiDAGDistribution
def test_extreme_sample():
"""Test that extreme probabilities give rise to expected graphs"""
n = 6
p = torch.tensor(1.0)
sample = ErdosRenyiDAGDistribution(num_nodes=n, probs=p).sample()
torch.testing.a... | torch.zeros_like(sample)) | assert_* | func_call | test/distributions/adjacency/test_erdos_renyi.py | test_extreme_sample | 40 | null | |
microsoft/causica | import numpy as np
import pandas as pd
import torch
from tensordict import TensorDict
from causica.datasets.causica_dataset_format import Variable, tensordict_from_variables_metadata
from causica.datasets.tensordict_utils import convert_one_hot, tensordict_from_pandas
def test_dataset_categorical():
"""Test the p... | (batch_size, 3) | assert | collection | test/datasets/test_datasets.py | test_dataset_categorical | 96 | null | |
microsoft/causica | from typing import Optional, Type, Union
import numpy as np
import pytest
import torch
from causica.distributions.adjacency import (
AdjacencyDistribution,
ConstrainedAdjacencyDistribution,
ENCOAdjacencyDistribution,
TemporalConstrainedAdjacencyDistribution,
ThreeWayAdjacencyDistribution,
)
from c... | None | assert | none_literal | test/distributions/adjacency/test_adjacency_distributions.py | _distribution_factory | 39 | null | |
microsoft/causica | import os
from pathlib import Path
import mlflow
import pytest
import yaml
from jsonargparse import Namespace
from mlflow import ActiveRun
from pytorch_lightning import LightningModule, Trainer
from pytorch_lightning.cli import LightningArgumentParser
from pytorch_lightning.trainer.states import TrainerFn
from causic... | namespace.as_dict() | assert | func_call | test/lightning/test_callbacks.py | test_mlflow_save_config_callback | 37 | null | |
microsoft/causica | import math
import pytest
import torch
from causica.distributions.noise import CategoricalNoise
def test_init():
base_logits = torch.Tensor([0.3, 0.2, 0.1])
# no batch
x_hat = torch.Tensor([0.3, 0.2, 0.1])
noise_model = CategoricalNoise(x_hat, base_logits)
assert noise_model.logits.shape == | torch.Size([3]) | assert | func_call | test/distributions/noise/test_categorical.py | test_init | 16 | null | |
microsoft/causica | import numpy as np
import pandas as pd
import torch
from tensordict import TensorDict
from causica.datasets.causica_dataset_format import Variable, tensordict_from_variables_metadata
from causica.datasets.tensordict_utils import convert_one_hot, tensordict_from_pandas
def test_dataset_categorical():
"""Test the p... | (batch_size, 2) | assert | collection | test/datasets/test_datasets.py | test_dataset_categorical | 92 | null | |
microsoft/causica | import pytest
import torch
import torch.distributions as td
from tensordict import TensorDict
from causica.datasets.variable_types import VariableTypeEnum
from causica.distributions import JointNoiseModule, create_noise_modules
from causica.distributions.noise.joint import ContinuousNoiseDist
from causica.functional_r... | torch.Size([10, 3, 2]) | assert | func_call | test/sem/test_sem.py | test_batched_intervention_batched_3d_graph | 218 | null | |
microsoft/causica | import logging
from dataclasses import asdict, is_dataclass
from typing import Any, Mapping, Optional, Sequence, Union
import fsspec
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.utilities.types import STEP_OUTPUT
from tensordict import TensorDict
from causica.datasets.causica_... | 1 | assert | numeric_literal | src/causica/lightning/modules/deci_module.py | test_step_observational | DECIModule | 258 | null |
microsoft/causica | import networkx as nx
import torch
from causica.distributions import StochasticBlockModelDAGDistribution
def test_samples_dags():
"""Test that all samples are DAGs"""
edges_per_node = [1, 2]
n = 5
num_blocks = [2, 3]
damping = [0.1, 0.2]
sample_shape = torch.Size([3, 4])
dist = StochasticB... | torch.Size(sample_shape + (n, n)) | assert | func_call | test/distributions/adjacency/test_stochastic_block_model.py | test_samples_dags | 18 | null | |
microsoft/causica | import gc
from causica.distributions.transforms.base import TypedTransform
def test_weak_ref_inv_release() -> None:
"""Test that the weak reference to the inverse is released."""
transform = _StrIntTransform()
inverse = transform.inv
id_ = id(inverse)
# Check that the inverse is kept while there ... | id_ | assert | variable | test/distributions/transforms/test_base.py | test_weak_ref_inv_release | 36 | null | |
microsoft/causica | import io
import itertools
from typing import Any, TypeVar
import pytest
import torch
from tensordict import TensorDictBase, make_tensordict
from causica.distributions.transforms import SequentialTransformModule
from causica.distributions.transforms.base import TransformModule
from causica.distributions.transforms.jo... | data) | assert_* | variable | test/distributions/transforms/test_transform_modules.py | test_transform_module_output | 56 | null | |
microsoft/causica | import pytest
import torch
import torch.distributions as td
from tensordict import TensorDict
from causica.datasets.variable_types import VariableTypeEnum
from causica.distributions import JointNoiseModule, create_noise_modules
from causica.distributions.noise.joint import ContinuousNoiseDist
from causica.functional_r... | inferred_noise) | assert_* | variable | test/sem/test_sem.py | test_intervention_batched_3d_graph | 184 | null | |
microsoft/causica | import networkx as nx
import torch
from causica.distributions import ErdosRenyiDAGDistribution
def test_num_deges():
num_edges = 16
samples = ErdosRenyiDAGDistribution(num_nodes=8, num_edges=torch.tensor(num_edges)).sample(torch.Size([100]))
assert samples.shape == torch.Size([100, 8, 8])
torch.testi... | torch.tensor(1, dtype=torch.float32)) | assert_* | func_call | test/distributions/adjacency/test_erdos_renyi.py | test_num_deges | 55 | null | |
microsoft/causica | import os
import pytest
import torch
from tensordict import TensorDict
from causica.datasets.causica_dataset_format import CAUSICA_DATASETS_PATH, DataEnum, load_data
from causica.datasets.tensordict_utils import tensordict_shapes
from causica.datasets.variable_types import VariableTypeEnum
from causica.distributions ... | tuple() | assert | func_call | test/integration/test_evaluation.py | test_evaluation_ate | 52 | null | |
microsoft/causica | import os
import tempfile
import numpy as np
import pytest
import torch
import torch.distributions as td
from tensordict import TensorDict
from causica.data_generation.generate_data import (
generate_sem_sampler,
get_variable_definitions,
plot_dataset,
sample_counterfactual,
sample_dataset,
sa... | shapes_dict["x_1"] | assert | complex_expr | test/data_generation/test_generate_data.py | test_sample_interventions | 110 | null | |
microsoft/causica | import pytest
import torch
from causica.distributions.adjacency.gibbs_dag_prior import ExpertGraphContainer, GibbsDAGPrior
def test_get_sparsity_term_temporal():
gibbs_dag_prior = GibbsDAGPrior(num_nodes=2, sparsity_lambda=torch.tensor(1), context_length=2)
empty_dag = torch.zeros(2, 3, 3)
assert gibbs_... | gibbs_dag_prior.get_sparsity_term(empty_dag) | assert | func_call | test/distributions/adjacency/test_gibbs_dag_prior.py | test_get_sparsity_term_temporal | 48 | null | |
microsoft/causica | import networkx as nx
import torch
from causica.distributions import ScaleFreeDAGDistribution
def test_out_degree():
n = 8
edges_per_node = [2]
power = [1.0]
in_degree = False
dag = ScaleFreeDAGDistribution(
num_nodes=n, edges_per_node=edges_per_node, power=power, in_degree=in_degree
)... | torch.Size([8, 8]) | assert | func_call | test/distributions/adjacency/test_scale_free.py | test_out_degree | 44 | null | |
run-llama/workflows-py | from pathlib import Path
import pytest
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
PersistentHandler,
)
from llama_agents.server.sqlite.sqlite_workflow_store import (
SqliteWorkflowStore,
)
from workflows.events import StopEvent
@pytest.mark.asyncio
@pytest.mark.parametrize(
... | event | assert | variable | packages/llama-agents-server/tests/server/test_sqlite_workflow_store.py | test_update_pydantic_result_serialization | 208 | null | |
run-llama/workflows-py | from __future__ import annotations
import asyncio
from typing import Any
import pytest
from workflows.runtime.types.named_task import PULL_PREFIX, NamedTask
async def _never_completes() -> None:
"""Coroutine that never completes, for creating pending tasks."""
await asyncio.Future()
def create_pending_task(... | task | assert | variable | packages/llama-index-workflows/tests/runtime/test_named_task.py | test_named_task_worker_creates_correct_key | 40 | null | |
run-llama/workflows-py | import inspect
from typing import Any, List, Optional, Union, get_type_hints
import pytest
from workflows.context import Context
from workflows.decorators import step
from workflows.errors import WorkflowValidationError
from workflows.events import StartEvent, StopEvent
from workflows.utils import (
_get_param_typ... | Any | assert | variable | packages/llama-index-workflows/tests/test_utils.py | test_get_param_types_no_annotations | 182 | null | |
run-llama/workflows-py | from datetime import datetime, timezone
import pytest
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
PersistentHandler,
)
from llama_agents.server.memory_workflow_store import MemoryWorkflowStore
from workflows.events import StopEvent
@pytest.mark.asyncio
async def test_update_on_conf... | "h2" | assert | string_literal | packages/llama-agents-server/tests/server/test_memory_workflow_store.py | test_update_on_conflict_overwrites_existing_row | 74 | null | |
run-llama/workflows-py | from __future__ import annotations
import json
import re
from pathlib import Path
from typing import Annotated, Optional
from unittest import mock
import pytest
from pydantic import BaseModel, Field
from workflows.decorators import step
from workflows.events import Event, StartEvent, StopEvent
from workflows.resource... | "r" | assert | string_literal | packages/llama-index-workflows/tests/test_resources.py | f1 | TestWorkflow | 311 | null |
run-llama/workflows-py | import os
from pathlib import Path
from typing import Any
from unittest.mock import patch
import pytest
from llama_agents.server.__main__ import run_server
def test_no_file_path_argument(capsys: Any) -> None:
"""Test that the script exits with usage message when no file path is provided."""
with patch("sys.ar... | 1 | assert | numeric_literal | packages/llama-agents-server/tests/server/test_main.py | test_no_file_path_argument | 20 | null | |
run-llama/workflows-py | from conftest import WorkflowFactory
from llama_agents_integration_tests.helpers import (
make_text_response,
make_tool_call_response,
)
from workflows import Context
from workflows.context import PickleSerializer
from workflows.events import HumanResponseEvent, InputRequiredEvent
async def test_context_dict_s... | None | assert | none_literal | packages/llama-agents-integration-tests/tests/test_human_in_the_loop.py | test_context_dict_serialization | 89 | null | |
run-llama/workflows-py | from typing import Any, cast
import pytest
from pydantic import PrivateAttr
from workflows.context import JsonSerializer
from workflows.events import (
Event,
StopEvent,
WorkflowCancelledEvent,
WorkflowFailedEvent,
WorkflowTimedOutEvent,
)
def test_workflow_timed_out_event_repr() -> None:
"""T... | rep | assert | variable | packages/llama-index-workflows/tests/test_event.py | test_workflow_timed_out_event_repr | 218 | null | |
run-llama/workflows-py | from __future__ import annotations
import sqlite3
from pathlib import Path
from typing import List
from llama_agents.server.sqlite.migrate import run_migrations
def _get_table_columns(conn: sqlite3.Connection, table: str) -> List[str]:
cursor = conn.execute(f"PRAGMA table_info({table})")
return [row[1] for r... | before | assert | variable | packages/llama-agents-server/tests/server/test_migrations.py | test_run_migrations_on_empty_db | 52 | null | |
run-llama/workflows-py | import inspect
from typing import Any, List, Optional, Union, get_type_hints
import pytest
from workflows.context import Context
from workflows.decorators import step
from workflows.errors import WorkflowValidationError
from workflows.events import StartEvent, StopEvent
from workflows.utils import (
_get_param_typ... | [str] | assert | collection | packages/llama-index-workflows/tests/test_utils.py | test_get_return_types | 200 | null | |
run-llama/workflows-py | from __future__ import annotations
import asyncio
from typing import AsyncGenerator, Optional, Union
import pytest
from pydantic import Field
from workflows.context import Context
from workflows.decorators import step
from workflows.errors import WorkflowTimeoutError
from workflows.events import (
Event,
Huma... | MyStop | assert | variable | packages/llama-agents-integration-tests/tests/test_runtime_matrix.py | test_custom_stop_event | 401 | null | |
run-llama/workflows-py | import asyncio
from typing import AsyncGenerator
import pytest
from httpx import ASGITransport, AsyncClient
from llama_agents.server import WorkflowServer
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
PersistentHandler,
)
from llama_agents.server.memory_workflow_store import MemoryWor... | "error" | assert | string_literal | packages/llama-agents-server/tests/server/test_server_persistence.py | test_store_is_updated_on_workflow_failure | 193 | null | |
run-llama/workflows-py | from conftest import WorkflowFactory
from llama_agents_integration_tests.helpers import (
make_text_response,
make_tool_call_response,
)
from workflows import Context
async def test_multiple_tools_share_state(create_workflow: WorkflowFactory) -> None:
"""Test that multiple different tools can share state."... | True | assert | bool_literal | packages/llama-agents-integration-tests/tests/test_context_store.py | test_multiple_tools_share_state | 189 | null | |
run-llama/workflows-py | import json
from collections.abc import Iterable, Mapping
from pathlib import Path
from typing import Annotated, Optional
import pytest
from pydantic import BaseModel
from workflows.decorators import step
from workflows.events import Event, StartEvent, StopEvent
from workflows.representation import (
WorkflowEvent... | 4 | assert | numeric_literal | packages/llama-index-workflows/tests/test_representation_utils.py | test_graph_with_all_node_types_serialization | 341 | null | |
run-llama/workflows-py | from llama_agents.server import WorkflowServer
from workflows import Workflow
def test_openapi_schema_includes_all_routes(simple_test_workflow: Workflow) -> None:
server = WorkflowServer()
server.add_workflow("test", simple_test_workflow)
schema = server.openapi_schema()
assert "paths" in schema
p... | paths | assert | variable | packages/llama-agents-server/tests/server/test_openapi_schema.py | test_openapi_schema_includes_all_routes | 30 | null | |
run-llama/workflows-py | from typing import Any, cast
import pytest
from pydantic import PrivateAttr
from workflows.context import JsonSerializer
from workflows.events import (
Event,
StopEvent,
WorkflowCancelledEvent,
WorkflowFailedEvent,
WorkflowTimedOutEvent,
)
def test_custom_event_with_fields_and_private_params() -> ... | "" | assert | string_literal | packages/llama-index-workflows/tests/test_event.py | test_custom_event_with_fields_and_private_params | 61 | null | |
run-llama/workflows-py | import asyncio
from typing import AsyncGenerator
import pytest
from httpx import ASGITransport, AsyncClient
from llama_agents.server import WorkflowServer
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
PersistentHandler,
)
from llama_agents.server.memory_workflow_store import MemoryWor... | 1 | assert | numeric_literal | packages/llama-agents-server/tests/server/test_server_persistence.py | test_resume_across_runs | 379 | null | |
run-llama/workflows-py | from __future__ import annotations
import pytest
def test_events_submodule_identity() -> None:
import llama_agents.workflows.events as alias_events
import workflows.events
assert alias_events is workflows.events
assert alias_events.Event is | workflows.events.Event | assert | complex_expr | packages/llama-index-workflows/tests/test_llama_agents_alias.py | test_events_submodule_identity | 45 | null | |
run-llama/workflows-py | import pytest
from conftest import WorkflowFactory
from llama_agents_integration_tests.helpers import (
make_text_response,
make_tool_call_response,
)
from workflows.errors import WorkflowRuntimeError
async def test_max_iterations_configurable_per_run(
create_workflow: WorkflowFactory,
) -> None:
"""Te... | 3 | assert | numeric_literal | packages/llama-agents-integration-tests/tests/test_error_handling.py | test_max_iterations_configurable_per_run | 116 | null | |
run-llama/workflows-py | from typing import Any, cast
import pytest
from pydantic import PrivateAttr
from workflows.context import JsonSerializer
from workflows.events import (
Event,
StopEvent,
WorkflowCancelledEvent,
WorkflowFailedEvent,
WorkflowTimedOutEvent,
)
def test_event_init_basic() -> None:
evt = Event(a=1, ... | "c" | assert | string_literal | packages/llama-index-workflows/tests/test_event.py | test_event_init_basic | 46 | null | |
run-llama/workflows-py | from __future__ import annotations
import pytest
def test_dunder_all_reexported() -> None:
import llama_agents.workflows as alias
import workflows
assert alias.__all__ == | workflows.__all__ | assert | complex_expr | packages/llama-index-workflows/tests/test_llama_agents_alias.py | test_dunder_all_reexported | 107 | null | |
run-llama/workflows-py | import httpx
import pytest
from client_test_workflows import (
GreetEvent,
InputEvent,
OutputEvent,
crashing_wf,
greeting_wf,
)
from httpx import ASGITransport, AsyncClient
from llama_agents.client import WorkflowClient
from llama_agents.client.protocol.serializable_events import (
EventEnvelope... | 1 | assert | numeric_literal | packages/llama-agents-client/tests/client/test_client.py | test_get_handlers | 111 | null | |
run-llama/workflows-py | from __future__ import annotations
import sqlite3
from pathlib import Path
from typing import List
from llama_agents.server.sqlite.migrate import run_migrations
def _get_table_columns(conn: sqlite3.Connection, table: str) -> List[str]:
cursor = conn.execute(f"PRAGMA table_info({table})")
return [row[1] for r... | 1 | assert | numeric_literal | packages/llama-agents-server/tests/server/test_migrations.py | test_migrate_from_version_1 | 74 | null | |
run-llama/workflows-py | import asyncio
from datetime import datetime, timedelta, timezone
from typing import Any, Optional
import pytest
import time_machine
from httpx import ASGITransport, AsyncClient
from llama_agents.server._handler import _WorkflowHandler
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
Per... | 2 | assert | numeric_literal | packages/llama-agents-server/tests/server/test_idle_release.py | test_is_idle_query_filter_memory_store | 155 | null | |
run-llama/workflows-py | from workflows.utils import _nanoid as nanoid
def test_nanoid_zero_length() -> None:
"""Test nanoid with zero length."""
result = nanoid(0)
assert len(result) == 0
assert result == | "" | assert | string_literal | packages/llama-index-workflows/tests/test_nanoid.py | test_nanoid_zero_length | 21 | null | |
run-llama/workflows-py | from conftest import SimpleWorkflowFactory, WorkflowFactory
from llama_agents_integration_tests.helpers import (
make_text_response,
make_tool_call_response,
)
from llama_index.core.agent.workflow import AgentOutput, ToolCall, ToolCallResult
async def test_stream_events_yields_events(
create_simple_workflo... | 0 | assert | numeric_literal | packages/llama-agents-integration-tests/tests/test_event_streaming.py | test_stream_events_yields_events | 33 | null | |
run-llama/workflows-py | import inspect
from typing import Any, List, Optional, Union, get_type_hints
import pytest
from workflows.context import Context
from workflows.decorators import step
from workflows.errors import WorkflowValidationError
from workflows.events import StartEvent, StopEvent
from workflows.utils import (
_get_param_typ... | True | assert | bool_literal | packages/llama-index-workflows/tests/test_utils.py | test_is_free_function | 225 | null | |
run-llama/workflows-py | from pathlib import Path
import pytest
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
PersistentHandler,
)
from llama_agents.server.sqlite.sqlite_workflow_store import (
SqliteWorkflowStore,
)
from workflows.events import StopEvent
@pytest.mark.asyncio
async def test_update_on_con... | [] | assert | collection | packages/llama-agents-server/tests/server/test_sqlite_workflow_store.py | test_update_on_conflict_overwrites_existing_row | 70 | null | |
run-llama/workflows-py | import os
from pathlib import Path
from typing import Any
from unittest.mock import patch
import pytest
from llama_agents.server.__main__ import run_server
def test_no_file_path_argument(capsys: Any) -> None:
"""Test that the script exits with usage message when no file path is provided."""
with patch("sys.ar... | captured.err | assert | complex_expr | packages/llama-agents-server/tests/server/test_main.py | test_no_file_path_argument | 22 | null | |
run-llama/workflows-py | from __future__ import annotations
import pytest
def test_context_submodule_identity() -> None:
import llama_agents.workflows.context as alias_ctx
import workflows.context
assert alias_ctx is | workflows.context | assert | complex_expr | packages/llama-index-workflows/tests/test_llama_agents_alias.py | test_context_submodule_identity | 58 | null | |
run-llama/workflows-py | from __future__ import annotations
import asyncio
from typing import AsyncGenerator, Optional, Union
import pytest
from pydantic import Field
from workflows.context import Context
from workflows.decorators import step
from workflows.errors import WorkflowTimeoutError
from workflows.events import (
Event,
Huma... | 0 | assert | numeric_literal | packages/llama-agents-integration-tests/tests/test_runtime_matrix.py | test_custom_stop_event | 414 | null | |
run-llama/workflows-py | from __future__ import annotations
import json
from pathlib import Path
from unittest.mock import Mock, patch
from urllib.error import HTTPError
import pytest
from dev_cli.changesets import (
PackageJson,
PyProjectContainer,
current_version,
is_published,
pep440_to_semver,
semver_to_pep440,
... | version | assert | variable | tests/dev_cli/test_changesets.py | test_semver_to_pep440_stable_passthrough | 229 | null | |
run-llama/workflows-py | import inspect
from typing import Any, List, Optional, Union, get_type_hints
import pytest
from workflows.context import Context
from workflows.decorators import step
from workflows.errors import WorkflowValidationError
from workflows.events import StartEvent, StopEvent
from workflows.utils import (
_get_param_typ... | str | assert | variable | packages/llama-index-workflows/tests/test_utils.py | test_get_param_types | 171 | null | |
run-llama/workflows-py | from __future__ import annotations
import json
from pathlib import Path
from unittest.mock import Mock, patch
from urllib.error import HTTPError
import pytest
from dev_cli.changesets import (
PackageJson,
PyProjectContainer,
current_version,
is_published,
pep440_to_semver,
semver_to_pep440,
... | "2.0.0" | assert | string_literal | tests/dev_cli/test_changesets.py | test_sync_package_version_updates_version | 128 | null | |
run-llama/workflows-py | import json
from pathlib import Path
from typing import Annotated
from unittest.mock import MagicMock, mock_open, patch
import pytest
from llama_index.utils.workflow import (
draw_all_possible_flows,
draw_all_possible_flows_mermaid,
draw_most_recent_execution,
draw_most_recent_execution_mermaid,
)
from... | 0 | assert | numeric_literal | packages/llama-index-utils-workflow/tests/test_drawing.py | test_mermaid_edges_generation | 161 | null | |
run-llama/workflows-py | import json
from pathlib import Path
from typing import Annotated
from unittest.mock import MagicMock, mock_open, patch
import pytest
from llama_index.utils.workflow import (
draw_all_possible_flows,
draw_all_possible_flows_mermaid,
draw_most_recent_execution,
draw_most_recent_execution_mermaid,
)
from... | "w") | assert_* | string_literal | packages/llama-index-utils-workflow/tests/test_drawing.py | test_draw_all_possible_flows_mermaid_basic | 97 | null | |
run-llama/workflows-py | from __future__ import annotations
import asyncio
import json
from collections import Counter
from contextlib import asynccontextmanager
from datetime import datetime
from types import SimpleNamespace
from typing import Any, AsyncGenerator, AsyncIterator
import pytest
import pytest_asyncio
from httpx import ASGITrans... | i | assert | variable | packages/llama-agents-server/tests/server/test_server_endpoints.py | test_stream_events_success | 455 | null | |
run-llama/workflows-py | import httpx
import pytest
from client_test_workflows import (
GreetEvent,
InputEvent,
OutputEvent,
crashing_wf,
greeting_wf,
)
from httpx import ASGITransport, AsyncClient
from llama_agents.client import WorkflowClient
from llama_agents.client.protocol.serializable_events import (
EventEnvelope... | result | assert | variable | packages/llama-agents-client/tests/client/test_client.py | test_get_result_for_handler | 82 | null | |
run-llama/workflows-py | from typing import Any, cast
import pytest
from pydantic import PrivateAttr
from workflows.context import JsonSerializer
from workflows.events import (
Event,
StopEvent,
WorkflowCancelledEvent,
WorkflowFailedEvent,
WorkflowTimedOutEvent,
)
def test_event_dict_api() -> None:
ev = _TestEvent(par... | 0 | assert | numeric_literal | packages/llama-index-workflows/tests/test_event.py | test_event_dict_api | 92 | null | |
run-llama/workflows-py | from __future__ import annotations
from typing import Any
import pytest
from workflows import Context, Workflow, step
from workflows.events import StartEvent, StopEvent
from workflows.plugins import BasicRuntime, basic_runtime, get_current_runtime
from workflows.testing import WorkflowTestRunner
async def test_regis... | 2 | assert | numeric_literal | packages/llama-index-workflows/tests/test_runtime_integration.py | test_registering_preserves_workflow_state | 121 | null | |
run-llama/workflows-py | from pathlib import Path
import pytest
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
PersistentHandler,
)
from llama_agents.server.sqlite.sqlite_workflow_store import (
SqliteWorkflowStore,
)
from workflows.events import StopEvent
@pytest.mark.asyncio
async def test_update_and_qu... | "h1" | assert | string_literal | packages/llama-agents-server/tests/server/test_sqlite_workflow_store.py | test_update_and_query_returns_inserted_handler | 35 | null | |
run-llama/workflows-py | import asyncio
from datetime import datetime, timedelta, timezone
from typing import Any, Optional
import pytest
import time_machine
from httpx import ASGITransport, AsyncClient
from llama_agents.server._handler import _WorkflowHandler
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
Per... | None | assert | none_literal | packages/llama-agents-server/tests/server/test_idle_release.py | get_handler_in_memory | 44 | null | |
run-llama/workflows-py | import json
import pytest
from llama_agents.client.protocol.serializable_events import (
EventEnvelope,
EventEnvelopeWithMetadata,
EventValidationError,
)
from workflows.events import (
Event,
StepState,
StepStateChanged,
StopEvent,
)
def test_parse_with_type_unknown_but_qualified_name_val... | 3 | assert | numeric_literal | packages/llama-agents-client/tests/protocol/test_serializable_events.py | test_parse_with_type_unknown_but_qualified_name_valid | 109 | null | |
run-llama/workflows-py | import re
import pytest
from workflows.decorators import step
from workflows.errors import WorkflowValidationError
from workflows.events import Event, StartEvent, StopEvent
from workflows.workflow import Workflow
def test_decorate_free_function() -> None:
class TestWorkflow(Workflow):
pass
@step(work... | {"f": f} | assert | collection | packages/llama-index-workflows/tests/test_decorator.py | test_decorate_free_function | 55 | null | |
run-llama/workflows-py | import pytest
from workflows import Context, Workflow, step
from workflows.events import (
Event,
StartEvent,
StepStateChanged,
StopEvent,
)
from workflows.testing import WorkflowTestRunner
from workflows.testing.runner import WorkflowTestResult
@pytest.mark.asyncio
async def test_testing_utils() -> No... | "done" | assert | string_literal | packages/llama-index-workflows/tests/test_testing_utils.py | test_testing_utils | 51 | null | |
run-llama/workflows-py | from __future__ import annotations
import asyncio
import json
from collections import Counter
from contextlib import asynccontextmanager
from datetime import datetime
from types import SimpleNamespace
from typing import Any, AsyncGenerator, AsyncIterator
import pytest
import pytest_asyncio
from httpx import ASGITrans... | 1 | assert | numeric_literal | packages/llama-agents-server/tests/server/test_server_endpoints.py | test_stream_events_single_consumer | 544 | null | |
run-llama/workflows-py | from pathlib import Path
import pytest
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
PersistentHandler,
)
from llama_agents.server.sqlite.sqlite_workflow_store import (
SqliteWorkflowStore,
)
from workflows.events import StopEvent
@pytest.mark.asyncio
async def test_update_and_qu... | 1 | assert | numeric_literal | packages/llama-agents-server/tests/server/test_sqlite_workflow_store.py | test_update_and_query_returns_inserted_handler | 33 | null | |
run-llama/workflows-py | from __future__ import annotations
import asyncio
import gc
import json
import logging
import pickle
import threading
import weakref
from typing import Any, Callable, Optional, cast
from unittest import mock
import pytest
from llama_index_instrumentation.dispatcher import (
active_instrument_tags,
instrument_... | "42" | assert | string_literal | packages/llama-index-workflows/tests/test_workflow.py | test_human_in_the_loop_with_resume | 320 | null | |
run-llama/workflows-py | from __future__ import annotations
import asyncio
import pytest
from llama_agents.server.keyed_lock import KeyedLock
def locks() -> KeyedLock:
return KeyedLock()
async def test_cancellation_cleanup(locks: KeyedLock) -> None:
"""Test that lock is released on task cancellation."""
started = asyncio.Event(... | asyncio.CancelledError) | pytest.raises | complex_expr | packages/llama-agents-server/tests/server/test_keyed_lock.py | test_cancellation_cleanup | 70 | null | |
run-llama/workflows-py | from __future__ import annotations
import json
import re
from pathlib import Path
from typing import Annotated, Optional
from unittest import mock
import pytest
from pydantic import BaseModel, Field
from workflows.decorators import step
from workflows.events import Event, StartEvent, StopEvent
from workflows.resource... | ["hello"] | assert | collection | packages/llama-index-workflows/tests/test_resources.py | test_resource_config_init | 156 | null | |
run-llama/workflows-py | import httpx
import pytest
from client_test_workflows import (
GreetEvent,
InputEvent,
OutputEvent,
crashing_wf,
greeting_wf,
)
from httpx import ASGITransport, AsyncClient
from llama_agents.client import WorkflowClient
from llama_agents.client.protocol.serializable_events import (
EventEnvelope... | None | assert | none_literal | packages/llama-agents-client/tests/client/test_client.py | test_get_result_for_handler | 76 | null | |
run-llama/workflows-py | from __future__ import annotations
import asyncio
import pytest
from workflows.context import Context
from workflows.decorators import step
from workflows.errors import ContextStateError, WorkflowRuntimeError
from workflows.events import StartEvent, StopEvent
from workflows.workflow import Workflow
@pytest.mark.asyn... | ctx_dict | assert | variable | packages/llama-index-workflows/tests/context/test_context_preservation.py | test_original_ctx_to_dict_works | 54 | null | |
run-llama/workflows-py | from __future__ import annotations
import asyncio
from typing import Any
import pytest
from workflows.runtime.types.named_task import PULL_PREFIX, NamedTask
async def _never_completes() -> None:
"""Coroutine that never completes, for creating pending tasks."""
await asyncio.Future()
def create_pending_task(... | w1 | assert | variable | packages/llama-index-workflows/tests/runtime/test_named_task.py | test_find_by_key_returns_worker_task | 128 | null | |
run-llama/workflows-py | from __future__ import annotations
import pytest
def test_events_submodule_identity() -> None:
import llama_agents.workflows.events as alias_events
import workflows.events
assert alias_events is | workflows.events | assert | complex_expr | packages/llama-index-workflows/tests/test_llama_agents_alias.py | test_events_submodule_identity | 44 | null | |
run-llama/workflows-py | import json
from collections.abc import Iterable, Mapping
from pathlib import Path
from typing import Annotated, Optional
import pytest
from pydantic import BaseModel
from workflows.decorators import step
from workflows.events import Event, StartEvent, StopEvent
from workflows.representation import (
WorkflowEvent... | 2 | assert | numeric_literal | packages/llama-index-workflows/tests/test_representation_utils.py | test_graph_serialization | 155 | null | |
run-llama/workflows-py | import httpx
import pytest
from client_test_workflows import (
GreetEvent,
InputEvent,
OutputEvent,
crashing_wf,
greeting_wf,
)
from httpx import ASGITransport, AsyncClient
from llama_agents.client import WorkflowClient
from llama_agents.client.protocol.serializable_events import (
EventEnvelope... | "sent" | assert | string_literal | packages/llama-agents-client/tests/client/test_client.py | test_send_event | 236 | null | |
run-llama/workflows-py | from __future__ import annotations
import pytest
def test_top_level_identity() -> None:
import llama_agents.workflows as alias
import workflows
assert alias.Workflow is | workflows.Workflow | assert | complex_expr | packages/llama-index-workflows/tests/test_llama_agents_alias.py | test_top_level_identity | 23 | null | |
run-llama/workflows-py | from datetime import datetime, timezone
import pytest
from llama_agents.server.abstract_workflow_store import (
HandlerQuery,
PersistentHandler,
)
from llama_agents.server.memory_workflow_store import MemoryWorkflowStore
from workflows.events import StopEvent
@pytest.mark.asyncio
async def test_update_and_que... | "h1" | assert | string_literal | packages/llama-agents-server/tests/server/test_memory_workflow_store.py | test_update_and_query_returns_inserted_handler | 32 | null | |
run-llama/workflows-py | from __future__ import annotations
import json
from pathlib import Path
from unittest.mock import Mock, patch
from urllib.error import HTTPError
import pytest
from dev_cli.changesets import (
PackageJson,
PyProjectContainer,
current_version,
is_published,
pep440_to_semver,
semver_to_pep440,
... | "1.2.3" | assert | string_literal | tests/dev_cli/test_changesets.py | test_current_version | 35 | null | |
run-llama/workflows-py | import json
import pytest
from llama_agents.client.protocol.serializable_events import (
EventEnvelope,
EventEnvelopeWithMetadata,
EventValidationError,
)
from workflows.events import (
Event,
StepState,
StepStateChanged,
StopEvent,
)
def test_parse_with_qualified_name_fallback_success() -... | 7 | assert | numeric_literal | packages/llama-agents-client/tests/protocol/test_serializable_events.py | test_parse_with_qualified_name_fallback_success | 101 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.