Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd8a0d4a

Browse files
committed
Small cleanups
1 parentb1e2f09 commitd8a0d4a

File tree

5 files changed

+24
-206
lines changed

5 files changed

+24
-206
lines changed

‎pgml-sdks/pgml/build.rs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::io::Write;
44

55
constADDITIONAL_DEFAULTS_FOR_PYTHON:&[u8] =br#"
66
def init_logger(level: Optional[str] = "", format: Optional[str] = "") -> None
7-
def SingleFieldPipeline(name: str, model: Optional[Model] = None, splitter: Optional[Splitter] = None, parameters: Optional[Json] = Any) ->MultiFieldPipeline
7+
def SingleFieldPipeline(name: str, model: Optional[Model] = None, splitter: Optional[Splitter] = None, parameters: Optional[Json] = Any) ->Pipeline
88
async def migrate() -> None
99
1010
Json = Any
@@ -15,7 +15,7 @@ GeneralJsonAsyncIterator = Any
1515

1616
constADDITIONAL_DEFAULTS_FOR_JAVASCRIPT:&[u8] =br#"
1717
export function init_logger(level?: string, format?: string): void;
18-
export function newSingleFieldPipeline(name: string, model?: Model, splitter?: Splitter, parameters?: Json):MultiFieldPipeline;
18+
export function newSingleFieldPipeline(name: string, model?: Model, splitter?: Splitter, parameters?: Json):Pipeline;
1919
export function migrate(): Promise<void>;
2020
2121
export type Json = any;
@@ -39,7 +39,6 @@ fn main() {
3939
remove_file(&path).ok();
4040
letmut file =OpenOptions::new()
4141
.create(true)
42-
.write(true)
4342
.append(true)
4443
.open(path)
4544
.unwrap();
@@ -53,7 +52,6 @@ fn main() {
5352
remove_file(&path).ok();
5453
letmut file =OpenOptions::new()
5554
.create(true)
56-
.write(true)
5755
.append(true)
5856
.open(path)
5957
.unwrap();

‎pgml-sdks/pgml/javascript/package-lock.json‎

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎pgml-sdks/pgml/src/collection.rs‎

Lines changed: 6 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ pub struct Collection {
129129
exists,
130130
archive,
131131
upsert_directory,
132-
upsert_file
132+
upsert_file,
133+
generate_er_diagram,
134+
get_pipeline_status
133135
)]
134136
implCollection{
135137
/// Creates a new [Collection]
@@ -259,25 +261,6 @@ impl Collection {
259261
}
260262

261263
/// Adds a new [Pipeline] to the [Collection]
262-
///
263-
/// # Arguments
264-
///
265-
/// * `pipeline` - The [Pipeline] to add.
266-
///
267-
/// # Example
268-
///
269-
/// ```
270-
/// use pgml::{Collection, Pipeline, Model, Splitter};
271-
///
272-
/// async fn example() -> anyhow::Result<()> {
273-
/// let model = Model::new(None, None, None);
274-
/// let splitter = Splitter::new(None, None);
275-
/// let mut pipeline = Pipeline::new("my_pipeline", None, None, None);
276-
/// let mut collection = Collection::new("my_collection", None);
277-
/// collection.add_pipeline(&mut pipeline).await?;
278-
/// Ok(())
279-
/// }
280-
/// ```
281264
#[instrument(skip(self))]
282265
pubasyncfnadd_pipeline(&mutself,pipeline:&mutPipeline) -> anyhow::Result<()>{
283266
// The flow for this function:
@@ -322,23 +305,6 @@ impl Collection {
322305
}
323306

324307
/// Removes a [Pipeline] from the [Collection]
325-
///
326-
/// # Arguments
327-
///
328-
/// * `pipeline` - The [Pipeline] to remove.
329-
///
330-
/// # Example
331-
///
332-
/// ```
333-
/// use pgml::{Collection, Pipeline};
334-
///
335-
/// async fn example() -> anyhow::Result<()> {
336-
/// let mut pipeline = Pipeline::new("my_pipeline", None, None, None);
337-
/// let mut collection = Collection::new("my_collection", None);
338-
/// collection.remove_pipeline(&mut pipeline).await?;
339-
/// Ok(())
340-
/// }
341-
/// ```
342308
#[instrument(skip(self))]
343309
pubasyncfnremove_pipeline(&mutself,pipeline:&Pipeline) -> anyhow::Result<()>{
344310
// The flow for this function:
@@ -368,29 +334,12 @@ impl Collection {
368334
}
369335

370336
/// Enables a [Pipeline] on the [Collection]
371-
///
372-
/// # Arguments
373-
///
374-
/// * `pipeline` - The [Pipeline] to enable
375-
///
376-
/// # Example
377-
///
378-
/// ```
379-
/// use pgml::{Collection, Pipeline};
380-
///
381-
/// async fn example() -> anyhow::Result<()> {
382-
/// let pipeline = Pipeline::new("my_pipeline", None, None, None);
383-
/// let collection = Collection::new("my_collection", None);
384-
/// collection.enable_pipeline(&pipeline).await?;
385-
/// Ok(())
386-
/// }
387-
/// ```
388337
#[instrument(skip(self))]
389338
pubasyncfnenable_pipeline(&mutself,pipeline:&mutPipeline) -> anyhow::Result<()>{
390339
// The flow for this function:
391340
// 1. Set ACTIVE = TRUE for the pipeline in collection.pipelines
392341
// 2. Resync the pipeline
393-
//TOOD: Review this pattern
342+
//TODO: Review this pattern
394343
self.verify_in_database(false).await?;
395344
let project_info =&self.database_data.as_ref().unwrap().project_info;
396345
let pool =get_or_initialize_pool(&self.database_url).await?;
@@ -407,23 +356,6 @@ impl Collection {
407356
}
408357

409358
/// Disables a [Pipeline] on the [Collection]
410-
///
411-
/// # Arguments
412-
///
413-
/// * `pipeline` - The [Pipeline] to disable
414-
///
415-
/// # Example
416-
///
417-
/// ```
418-
/// use pgml::{Collection, Pipeline};
419-
///
420-
/// async fn example() -> anyhow::Result<()> {
421-
/// let pipeline = Pipeline::new("my_pipeline", None, None, None);
422-
/// let collection = Collection::new("my_collection", None);
423-
/// collection.disable_pipeline(&pipeline).await?;
424-
/// Ok(())
425-
/// }
426-
/// ```
427359
#[instrument(skip(self))]
428360
pubasyncfndisable_pipeline(&self,pipeline:&Pipeline) -> anyhow::Result<()>{
429361
// The flow for this function:
@@ -459,27 +391,6 @@ impl Collection {
459391
}
460392

461393
/// Upserts documents into the database
462-
///
463-
/// # Arguments
464-
///
465-
/// * `documents` - A vector of documents to upsert
466-
/// * `strict` - Whether to throw an error if keys: `id` or `text` are missing from any documents
467-
///
468-
/// # Example
469-
///
470-
/// ```
471-
/// use pgml::Collection;
472-
///
473-
/// async fn example() -> anyhow::Result<()> {
474-
/// let mut collection = Collection::new("my_collection", None);
475-
/// let documents = vec![
476-
/// serde_json::json!({"id": 1, "text": "hello world"}).into(),
477-
/// serde_json::json!({"id": 2, "text": "hello world"}).into(),
478-
/// ];
479-
/// collection.upsert_documents(documents, None).await?;
480-
/// Ok(())
481-
/// }
482-
/// ```
483394
#[instrument(skip(self, documents))]
484395
pubasyncfnupsert_documents(
485396
&mutself,
@@ -647,21 +558,6 @@ impl Collection {
647558
}
648559

649560
/// Gets the documents on a [Collection]
650-
///
651-
/// # Arguments
652-
///
653-
/// * `args` - The filters and options to apply to the query
654-
///
655-
/// # Example
656-
///
657-
/// ```
658-
/// use pgml::Collection;
659-
///
660-
/// async fn example() -> anyhow::Result<()> {
661-
/// let mut collection = Collection::new("my_collection", None);
662-
/// let documents = collection.get_documents(None).await?;
663-
/// Ok(())
664-
/// }
665561
#[instrument(skip(self))]
666562
pubasyncfnget_documents(&self,args:Option<Json>) -> anyhow::Result<Vec<Json>>{
667563
let pool =get_or_initialize_pool(&self.database_url).await?;
@@ -721,25 +617,6 @@ impl Collection {
721617
}
722618

723619
/// Deletes documents in a [Collection]
724-
///
725-
/// # Arguments
726-
///
727-
/// * `filter` - The filters to apply
728-
///
729-
/// # Example
730-
///
731-
/// ```
732-
/// use pgml::Collection;
733-
///
734-
/// async fn example() -> anyhow::Result<()> {
735-
/// let mut collection = Collection::new("my_collection", None);
736-
/// let documents = collection.delete_documents(serde_json::json!({
737-
/// "id": {
738-
/// "eq": 1
739-
/// }
740-
/// }).into()).await?;
741-
/// Ok(())
742-
/// }
743620
#[instrument(skip(self))]
744621
pubasyncfndelete_documents(&self,filter:Json) -> anyhow::Result<()>{
745622
let pool =get_or_initialize_pool(&self.database_url).await?;
@@ -832,25 +709,6 @@ impl Collection {
832709
}
833710

834711
/// Performs vector search on the [Collection]
835-
///
836-
/// # Arguments
837-
///
838-
/// * `query` - The query to search for
839-
/// * `pipeline` - The [Pipeline] used for the search
840-
/// * `query_paramaters` - The query parameters passed to the model for search
841-
///
842-
/// # Example
843-
///
844-
/// ```
845-
/// use pgml::{Collection, Pipeline};
846-
///
847-
/// async fn example() -> anyhow::Result<()> {
848-
/// let mut collection = Collection::new("my_collection", None);
849-
/// let mut pipeline = Pipeline::new("my_pipeline", None, None, None);
850-
/// let results = collection.vector_search("Query", &mut pipeline, None, None).await?;
851-
/// Ok(())
852-
/// }
853-
/// ```
854712
#[instrument(skip(self))]
855713
#[allow(clippy::type_complexity)]
856714
pubasyncfnvector_search(
@@ -956,18 +814,6 @@ impl Collection {
956814
}
957815

958816
/// Gets all pipelines for the [Collection]
959-
///
960-
/// # Example
961-
///
962-
/// ```
963-
/// use pgml::Collection;
964-
///
965-
/// async fn example() -> anyhow::Result<()> {
966-
/// let mut collection = Collection::new("my_collection", None);
967-
/// let pipelines = collection.get_pipelines().await?;
968-
/// Ok(())
969-
/// }
970-
/// ```
971817
#[instrument(skip(self))]
972818
pubasyncfnget_pipelines(&mutself) -> anyhow::Result<Vec<Pipeline>>{
973819
self.verify_in_database(false).await?;
@@ -982,18 +828,6 @@ impl Collection {
982828
}
983829

984830
/// Gets a [Pipeline] by name
985-
///
986-
/// # Example
987-
///
988-
/// ```
989-
/// use pgml::Collection;
990-
///
991-
/// async fn example() -> anyhow::Result<()> {
992-
/// let mut collection = Collection::new("my_collection", None);
993-
/// let pipeline = collection.get_pipeline("my_pipeline").await?;
994-
/// Ok(())
995-
/// }
996-
/// ```
997831
#[instrument(skip(self))]
998832
pubasyncfnget_pipeline(&mutself,name:&str) -> anyhow::Result<Pipeline>{
999833
self.verify_in_database(false).await?;
@@ -1009,18 +843,6 @@ impl Collection {
1009843
}
1010844

1011845
/// Check if the [Collection] exists in the database
1012-
///
1013-
/// # Example
1014-
///
1015-
/// ```
1016-
/// use pgml::Collection;
1017-
///
1018-
/// async fn example() -> anyhow::Result<()> {
1019-
/// let collection = Collection::new("my_collection", None);
1020-
/// let exists = collection.exists().await?;
1021-
/// Ok(())
1022-
/// }
1023-
/// ```
1024846
#[instrument(skip(self))]
1025847
pubasyncfnexists(&self) -> anyhow::Result<bool>{
1026848
let pool =get_or_initialize_pool(&self.database_url).await?;
@@ -1108,13 +930,15 @@ impl Collection {
1108930
Ok(())
1109931
}
1110932

933+
#[instrument(skip(self))]
1111934
pubasyncfnget_pipeline_status(&mutself,pipeline:&mutPipeline) -> anyhow::Result<Json>{
1112935
self.verify_in_database(false).await?;
1113936
let project_info =&self.database_data.as_ref().unwrap().project_info;
1114937
let pool =get_or_initialize_pool(&self.database_url).await?;
1115938
pipeline.get_status(project_info,&pool).await
1116939
}
1117940

941+
#[instrument(skip(self))]
1118942
pubasyncfngenerate_er_diagram(&mutself,pipeline:&mutPipeline) -> anyhow::Result<String>{
1119943
self.verify_in_database(false).await?;
1120944
let project_info =&self.database_data.as_ref().unwrap().project_info;

‎pgml-sdks/pgml/src/pipeline.rs‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,6 @@ impl Pipeline {
214214
}
215215

216216
/// Gets the status of the [Pipeline]
217-
/// This includes the status of the chunks, embeddings, and tsvectors
218-
///
219-
/// # Example
220-
///
221-
/// ```
222-
/// use pgml::Collection;
223-
///
224-
/// async fn example() -> anyhow::Result<()> {
225-
/// let mut collection = Collection::new("my_collection", None);
226-
/// let mut pipeline = collection.get_pipeline("my_pipeline").await?;
227-
/// let status = pipeline.get_status().await?;
228-
/// Ok(())
229-
/// }
230-
/// ```
231217
#[instrument(skip(self))]
232218
pubasyncfnget_status(
233219
&mutself,
@@ -778,7 +764,6 @@ impl Pipeline {
778764
pub(crate)asyncfnresync(
779765
&mutself,
780766
project_info:&ProjectInfo,
781-
// pool: &Pool<Postgres>,
782767
connection:&mutPgConnection,
783768
) -> anyhow::Result<()>{
784769
// We are assuming we have manually verified the pipeline before doing this

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp