def run_test_backfill(execution_args, expected_count=None, error_message=None): runner = CliRunner() run_launcher = InMemoryRunLauncher() with seven.TemporaryDirectory() as temp_dir: instance = DagsterInstance( instance_type=InstanceType.EPHEMERAL, local_artifact_storage=LocalArtifactStorage(temp_dir), run_storage=InMemoryRunStorage(), event_storage=InMemoryEventLogStorage(), compute_log_manager=NoOpComputeLogManager(), run_launcher=run_launcher, ) with mock.patch( 'dagster.core.instance.DagsterInstance.get') as _instance: _instance.return_value = instance if error_message: with pytest.raises(UsageError) as error_info: execute_backfill_command( backfill_execute_args(execution_args), no_print) assert error_info and error_message in error_info.value.message result = runner.invoke(pipeline_backfill_command, backfill_cli_runner_args(execution_args)) if error_message: assert result.exit_code == 2 else: assert result.exit_code == 0 if expected_count: assert len(run_launcher.queue()) == expected_count
def run_test_backfill_inner(execution_args, instance, expected_count, error_message): if error_message: with pytest.raises(Exception): execute_backfill_command(execution_args, print, instance) else: execute_backfill_command(execution_args, print, instance) if expected_count: assert instance.get_runs_count() == expected_count
def job_backfill_command(**kwargs): with DagsterInstance.get() as instance: execute_backfill_command(kwargs, click.echo, instance, True)