Skip to content

Commit 41e6c97

Browse files
committed
style: rename ResourceSetupStatusCheck to ResourceSetupStatus
1 parent bbdff69 commit 41e6c97

File tree

17 files changed

+145
-142
lines changed

17 files changed

+145
-142
lines changed

python/cocoindex/cli.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ def setup():
8585
Check and apply backend setup changes for flows, including the internal and target storage
8686
(to export).
8787
"""
88-
status_check = sync_setup()
89-
click.echo(status_check)
90-
if status_check.is_up_to_date():
88+
setup_status = sync_setup()
89+
click.echo(setup_status)
90+
if setup_status.is_up_to_date():
9191
click.echo("No changes need to be pushed.")
9292
return
9393
if not click.confirm(
9494
"Changes need to be pushed. Continue? [yes/N]", default=False, show_default=False):
9595
return
96-
apply_setup_changes(status_check)
96+
apply_setup_changes(setup_status)
9797

9898
@cli.command()
9999
@click.argument("flow_name", type=str, nargs=-1)
@@ -112,15 +112,15 @@ def drop(flow_name: tuple[str, ...], drop_all: bool):
112112
flow_names = [fl.name for fl in flow.flows()]
113113
else:
114114
flow_names = list(flow_name)
115-
status_check = drop_setup(flow_names)
116-
click.echo(status_check)
117-
if status_check.is_up_to_date():
115+
setup_status = drop_setup(flow_names)
116+
click.echo(setup_status)
117+
if setup_status.is_up_to_date():
118118
click.echo("No flows need to be dropped.")
119119
return
120120
if not click.confirm(
121121
"Changes need to be pushed. Continue? [yes/N]", default=False, show_default=False):
122122
return
123-
apply_setup_changes(status_check)
123+
apply_setup_changes(setup_status)
124124

125125
@cli.command()
126126
@click.argument("flow_name", type=str, required=False)

python/cocoindex/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
from . import flow
22
from . import _engine
33

4-
def sync_setup() -> _engine.SetupStatusCheck:
4+
def sync_setup() -> _engine.SetupStatus:
55
flow.ensure_all_flows_built()
66
return _engine.sync_setup()
77

8-
def drop_setup(flow_names: list[str]) -> _engine.SetupStatusCheck:
8+
def drop_setup(flow_names: list[str]) -> _engine.SetupStatus:
99
flow.ensure_all_flows_built()
1010
return _engine.drop_setup(flow_names)
1111

1212
def flow_names_with_setup() -> list[str]:
1313
return _engine.flow_names_with_setup()
1414

15-
def apply_setup_changes(status_check: _engine.SetupStatusCheck):
16-
_engine.apply_setup_changes(status_check)
15+
def apply_setup_changes(setup_status: _engine.SetupStatus):
16+
_engine.apply_setup_changes(setup_status)

src/builder/analyzed_flow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::{analyzer, plan};
44
use crate::{
55
ops::registry::ExecutorFactoryRegistry,
66
service::error::{shared_ok, SharedError, SharedResultExt},
7-
setup::{self, ObjectSetupStatusCheck},
7+
setup::{self, ObjectSetupStatus},
88
};
99

1010
pub struct AnalyzedFlow {
@@ -29,9 +29,9 @@ impl AnalyzedFlow {
2929
existing_flow_ss,
3030
registry,
3131
)?;
32-
let setup_status_check =
32+
let setup_status =
3333
setup::check_flow_setup_status(Some(&desired_state), existing_flow_ss).await?;
34-
let execution_plan = if setup_status_check.is_up_to_date() {
34+
let execution_plan = if setup_status.is_up_to_date() {
3535
Some(
3636
async move {
3737
shared_ok(Arc::new(

src/execution/db_tracking_setup.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::prelude::*;
22

3-
use crate::setup::{CombinedState, ResourceSetupInfo, ResourceSetupStatusCheck, SetupChangeType};
3+
use crate::setup::{CombinedState, ResourceSetupInfo, ResourceSetupStatus, SetupChangeType};
44
use serde::{Deserialize, Serialize};
55
use sqlx::PgPool;
66

@@ -53,7 +53,7 @@ pub struct TrackingTableSetupState {
5353
}
5454

5555
#[derive(Debug)]
56-
pub struct TrackingTableSetupStatusCheck {
56+
pub struct TrackingTableSetupStatus {
5757
pub desired_state: Option<TrackingTableSetupState>,
5858

5959
pub legacy_table_names: Vec<String>,
@@ -62,7 +62,7 @@ pub struct TrackingTableSetupStatusCheck {
6262
pub source_ids_to_delete: Vec<i32>,
6363
}
6464

65-
impl TrackingTableSetupStatusCheck {
65+
impl TrackingTableSetupStatus {
6666
pub fn new(
6767
desired: Option<&TrackingTableSetupState>,
6868
existing: &CombinedState<TrackingTableSetupState>,
@@ -91,19 +91,19 @@ impl TrackingTableSetupStatusCheck {
9191

9292
pub fn into_setup_info(
9393
self,
94-
) -> ResourceSetupInfo<(), TrackingTableSetupState, TrackingTableSetupStatusCheck> {
94+
) -> ResourceSetupInfo<(), TrackingTableSetupState, TrackingTableSetupStatus> {
9595
ResourceSetupInfo {
9696
key: (),
9797
state: self.desired_state.clone(),
9898
description: "Tracking Table".to_string(),
99-
status_check: Some(self),
99+
setup_status: Some(self),
100100
legacy_key: None,
101101
}
102102
}
103103
}
104104

105105
#[async_trait]
106-
impl ResourceSetupStatusCheck for TrackingTableSetupStatusCheck {
106+
impl ResourceSetupStatus for TrackingTableSetupStatus {
107107
fn describe_changes(&self) -> Vec<String> {
108108
let mut changes: Vec<String> = vec![];
109109
if self.desired_state.is_some() && !self.legacy_table_names.is_empty() {

src/llm/anthropic.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
use crate::llm::{
2+
LlmGenerateRequest, LlmGenerateResponse, LlmGenerationClient, LlmSpec, OutputFormat,
3+
ToJsonSchemaOptions,
4+
};
5+
use anyhow::{bail, Context, Result};
16
use async_trait::async_trait;
2-
use crate::llm::{LlmGenerationClient, LlmSpec, LlmGenerateRequest, LlmGenerateResponse, ToJsonSchemaOptions, OutputFormat};
3-
use anyhow::{Result, bail, Context};
4-
use serde_json::Value;
57
use json5;
8+
use serde_json::Value;
69

710
use crate::api_bail;
811
use urlencoding::encode;
@@ -64,7 +67,8 @@ impl LlmGenerationClient for Client {
6467

6568
let encoded_api_key = encode(&self.api_key);
6669

67-
let resp = self.client
70+
let resp = self
71+
.client
6872
.post(url)
6973
.header("x-api-key", encoded_api_key.as_ref())
7074
.header("anthropic-version", "2023-06-01")
@@ -81,7 +85,7 @@ impl LlmGenerationClient for Client {
8185
// println!("Anthropic API full response: {resp_json:?}");
8286

8387
let resp_content = &resp_json["content"];
84-
let tool_name = "report_result";
88+
let tool_name = "report_result";
8589
let mut extracted_json: Option<Value> = None;
8690
if let Some(array) = resp_content.as_array() {
8791
for item in array {
@@ -116,14 +120,16 @@ impl LlmGenerationClient for Client {
116120
}
117121
}
118122
}
119-
},
120-
_ => return Err(anyhow::anyhow!("No structured tool output or text found in response")),
123+
}
124+
_ => {
125+
return Err(anyhow::anyhow!(
126+
"No structured tool output or text found in response"
127+
))
128+
}
121129
}
122130
};
123131

124-
Ok(LlmGenerateResponse {
125-
text,
126-
})
132+
Ok(LlmGenerateResponse { text })
127133
}
128134

129135
fn json_schema_options(&self) -> ToJsonSchemaOptions {

src/llm/gemini.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
use crate::api_bail;
2+
use crate::llm::{
3+
LlmGenerateRequest, LlmGenerateResponse, LlmGenerationClient, LlmSpec, OutputFormat,
4+
ToJsonSchemaOptions,
5+
};
6+
use anyhow::{bail, Context, Result};
17
use async_trait::async_trait;
2-
use crate::llm::{LlmGenerationClient, LlmSpec, LlmGenerateRequest, LlmGenerateResponse, ToJsonSchemaOptions, OutputFormat};
3-
use anyhow::{Result, bail, Context};
48
use serde_json::Value;
5-
use crate::api_bail;
69
use urlencoding::encode;
710

811
pub struct Client {
@@ -76,10 +79,13 @@ impl LlmGenerationClient for Client {
7679
let api_key = &self.api_key;
7780
let url = format!(
7881
"https://generativelanguage.googleapis.com/v1beta/models/{}:generateContent?key={}",
79-
encode(&self.model), encode(api_key)
82+
encode(&self.model),
83+
encode(api_key)
8084
);
8185

82-
let resp = self.client.post(&url)
86+
let resp = self
87+
.client
88+
.post(&url)
8389
.json(&payload)
8490
.send()
8591
.await
@@ -107,4 +113,4 @@ impl LlmGenerationClient for Client {
107113
top_level_must_be_object: true,
108114
}
109115
}
110-
}
116+
}

src/llm/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ pub trait LlmGenerationClient: Send + Sync {
5252
fn json_schema_options(&self) -> ToJsonSchemaOptions;
5353
}
5454

55+
mod anthropic;
56+
mod gemini;
5557
mod ollama;
5658
mod openai;
57-
mod gemini;
58-
mod anthropic;
5959

6060
pub async fn new_llm_generation_client(spec: LlmSpec) -> Result<Box<dyn LlmGenerationClient>> {
6161
let client = match spec.api_type {

src/ops/factory_bases.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub trait StorageFactoryBase: ExportTargetFactory + Send + Sync + 'static {
310310
desired_state: Option<Self::SetupState>,
311311
existing_states: setup::CombinedState<Self::SetupState>,
312312
auth_registry: &Arc<AuthRegistry>,
313-
) -> Result<impl setup::ResourceSetupStatusCheck + 'static>;
313+
) -> Result<impl setup::ResourceSetupStatus + 'static>;
314314

315315
fn check_state_compatibility(
316316
&self,
@@ -398,21 +398,21 @@ impl<T: StorageFactoryBase> ExportTargetFactory for T {
398398
desired_state: Option<serde_json::Value>,
399399
existing_states: setup::CombinedState<serde_json::Value>,
400400
auth_registry: &Arc<AuthRegistry>,
401-
) -> Result<Box<dyn setup::ResourceSetupStatusCheck>> {
401+
) -> Result<Box<dyn setup::ResourceSetupStatus>> {
402402
let key: T::Key = serde_json::from_value(key.clone())?;
403403
let desired_state: Option<T::SetupState> = desired_state
404404
.map(|v| serde_json::from_value(v.clone()))
405405
.transpose()?;
406406
let existing_states = from_json_combined_state(existing_states)?;
407-
let status_check = StorageFactoryBase::check_setup_status(
407+
let setup_status = StorageFactoryBase::check_setup_status(
408408
self,
409409
key,
410410
desired_state,
411411
existing_states,
412412
auth_registry,
413413
)
414414
.await?;
415-
Ok(Box::new(status_check))
415+
Ok(Box::new(setup_status))
416416
}
417417

418418
fn describe_resource(&self, key: &serde_json::Value) -> Result<String> {

src/ops/interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub trait ExportTargetFactory: Send + Sync {
196196
desired_state: Option<serde_json::Value>,
197197
existing_states: setup::CombinedState<serde_json::Value>,
198198
auth_registry: &Arc<AuthRegistry>,
199-
) -> Result<Box<dyn setup::ResourceSetupStatusCheck>>;
199+
) -> Result<Box<dyn setup::ResourceSetupStatus>>;
200200

201201
/// Normalize the key. e.g. the JSON format may change (after code change, e.g. new optional field or field ordering), even if the underlying value is not changed.
202202
/// This should always return the canonical serialized form.

src/ops/storages/neo4j.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::prelude::*;
22

33
use super::spec::{GraphDeclaration, GraphElementMapping, NodeFromFieldsSpec, TargetFieldMapping};
44
use crate::setup::components::{self, State};
5-
use crate::setup::{ResourceSetupStatusCheck, SetupChangeType};
5+
use crate::setup::{ResourceSetupStatus, SetupChangeType};
66
use crate::{ops::sdk::*, setup::CombinedState};
77

88
use indoc::formatdoc;
@@ -855,7 +855,7 @@ fn build_composite_field_names(qualifier: &str, field_names: &[String]) -> Strin
855855
}
856856
#[derive(Derivative)]
857857
#[derivative(Debug)]
858-
struct SetupStatusCheck {
858+
struct SetupStatus {
859859
key: GraphElement,
860860
#[derivative(Debug = "ignore")]
861861
graph_pool: Arc<GraphPool>,
@@ -864,7 +864,7 @@ struct SetupStatusCheck {
864864
change_type: SetupChangeType,
865865
}
866866

867-
impl SetupStatusCheck {
867+
impl SetupStatus {
868868
fn new(
869869
key: GraphElement,
870870
graph_pool: Arc<GraphPool>,
@@ -908,7 +908,7 @@ impl SetupStatusCheck {
908908
}
909909

910910
#[async_trait]
911-
impl ResourceSetupStatusCheck for SetupStatusCheck {
911+
impl ResourceSetupStatus for SetupStatus {
912912
fn describe_changes(&self) -> Vec<String> {
913913
let mut result = vec![];
914914
if let Some(data_clear) = &self.data_clear {
@@ -1255,24 +1255,24 @@ impl StorageFactoryBase for Factory {
12551255
desired: Option<SetupState>,
12561256
existing: CombinedState<SetupState>,
12571257
auth_registry: &Arc<AuthRegistry>,
1258-
) -> Result<impl ResourceSetupStatusCheck + 'static> {
1258+
) -> Result<impl ResourceSetupStatus + 'static> {
12591259
let conn_spec = auth_registry.get::<ConnectionSpec>(&key.connection)?;
1260-
let base = SetupStatusCheck::new(
1260+
let base = SetupStatus::new(
12611261
key,
12621262
self.graph_pool.clone(),
12631263
conn_spec.clone(),
12641264
desired.as_ref(),
12651265
&existing,
12661266
);
1267-
let comp = components::StatusCheck::create(
1267+
let comp = components::Status::create(
12681268
SetupComponentOperator {
12691269
graph_pool: self.graph_pool.clone(),
12701270
conn_spec: conn_spec.clone(),
12711271
},
12721272
desired,
12731273
existing,
12741274
)?;
1275-
Ok(components::combine_status_checks(base, comp))
1275+
Ok(components::combine_setup_statuss(base, comp))
12761276
}
12771277

12781278
fn check_state_compatibility(

src/ops/storages/postgres.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ impl TableSetupAction {
575575
}
576576

577577
#[derive(Debug)]
578-
pub struct SetupStatusCheck {
578+
pub struct SetupStatus {
579579
db_pool: PgPool,
580580
table_name: String,
581581

@@ -585,7 +585,7 @@ pub struct SetupStatusCheck {
585585
desired_table_setup: Option<TableSetupAction>,
586586
}
587587

588-
impl SetupStatusCheck {
588+
impl SetupStatus {
589589
fn new(
590590
db_pool: PgPool,
591591
table_name: String,
@@ -739,7 +739,7 @@ fn describe_index_spec(index_name: &str, index_spec: &VectorIndexDef) -> String
739739
}
740740

741741
#[async_trait]
742-
impl setup::ResourceSetupStatusCheck for SetupStatusCheck {
742+
impl setup::ResourceSetupStatus for SetupStatus {
743743
fn describe_changes(&self) -> Vec<String> {
744744
let mut descriptions = vec![];
745745
if self.drop_existing {
@@ -976,8 +976,8 @@ impl StorageFactoryBase for Factory {
976976
desired: Option<SetupState>,
977977
existing: setup::CombinedState<SetupState>,
978978
auth_registry: &Arc<AuthRegistry>,
979-
) -> Result<impl setup::ResourceSetupStatusCheck + 'static> {
980-
Ok(SetupStatusCheck::new(
979+
) -> Result<impl setup::ResourceSetupStatus + 'static> {
980+
Ok(SetupStatus::new(
981981
get_db_pool(key.database.as_ref(), auth_registry).await?,
982982
key.table_name,
983983
desired,

src/ops/storages/qdrant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl StorageFactoryBase for Arc<Factory> {
390390
_desired: Option<()>,
391391
_existing: setup::CombinedState<()>,
392392
_auth_registry: &Arc<AuthRegistry>,
393-
) -> Result<impl setup::ResourceSetupStatusCheck + 'static> {
393+
) -> Result<impl setup::ResourceSetupStatus + 'static> {
394394
Err(anyhow!("Set `setup_by_user` to `true` to export to Qdrant")) as Result<Infallible, _>
395395
}
396396

0 commit comments

Comments
 (0)