Skip to content

Commit

Permalink
Service COllecvtion
Browse files Browse the repository at this point in the history
  • Loading branch information
clun committed Nov 25, 2024
1 parent 8ab22c2 commit a7179f7
Show file tree
Hide file tree
Showing 7 changed files with 358 additions and 6 deletions.
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<astra-sdk.version>1.2.8</astra-sdk.version>
<astra-db-java.version>1.4.3</astra-db-java.version>
<astra-db-java.version>1.4.5</astra-db-java.version>
<jansi.version>2.4.1</jansi.version>
<airline.version>3.0.0</airline.version>
<slf4j.version>2.0.13</slf4j.version>
Expand Down Expand Up @@ -122,6 +122,20 @@
<version>${awaitibility.version}</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.github.rvesse/airline-help-markdown -->
<dependency>
<groupId>com.github.rvesse</groupId>
<artifactId>airline-help-markdown</artifactId>
<version>${airline.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.rvesse</groupId>
<artifactId>airline-help-html</artifactId>
<version>${airline.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ public void listEmbeddingProviders(String databaseName) {
Map<String, EmbeddingProvider> myCollec = dbDao
.getDataAPIDatabase(databaseName)
.getDatabaseAdmin()
.listEmbeddingProviders();
.findEmbeddingProviders()
.getEmbeddingProviders();
for (Map.Entry<String, EmbeddingProvider> entry : myCollec.entrySet()) {
EmbeddingProvider vOptions = entry.getValue();
Map<String, String> rf = new HashMap<>();
Expand Down Expand Up @@ -312,7 +313,8 @@ public void describeEmbeddingProvider(String databaseName, String key) {
Map<String, EmbeddingProvider> providers = dbDao
.getDataAPIDatabase(databaseName)
.getDatabaseAdmin()
.listEmbeddingProviders();
.findEmbeddingProviders()
.getEmbeddingProviders();
if (!providers.containsKey(key)) {
throw new IllegalArgumentException("Embedding provider '" + key + "' has not been found");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.dtsx.astra.cli.docs;

import com.dtsx.astra.cli.AstraCli;
import com.github.rvesse.airline.Cli;
import com.github.rvesse.airline.help.GlobalUsageGenerator;
import com.github.rvesse.airline.help.markdown.MarkdownMultiPageGlobalUsageGenerator;
import org.junit.jupiter.api.Test;

import java.io.FileOutputStream;
import java.io.IOException;

public class MarkDownDocumentationGenerator {

@Test
public void generateMDDocumentation() {
Cli<Runnable> cli = new Cli<>(AstraCli.class);

GlobalUsageGenerator<Runnable> helpGenerator = new MarkdownMultiPageGlobalUsageGenerator<>();
try {
//helpGenerator.usage(cli.getMetadata(), System.out);

FileOutputStream out = new FileOutputStream("cli.md");
helpGenerator.usage(cli.getMetadata(), out);

} catch (IOException e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public void shouldShowHelp() {
assertSuccessCli("help db delete-collection");
assertSuccessCli("help db create-collection");
assertSuccessCli("help db list-collections");

}

@Test
Expand Down Expand Up @@ -99,7 +98,6 @@ public void shouldCleanCollections() {
assertSuccessCli("db delete-collection %s --collection %s".formatted(DB_TEST_VECTOR, TEST_COLLECTION_VECTOR));
}


@Test
@Order(9)
public void shouldFindEmbeddingProvider() {
Expand All @@ -113,7 +111,9 @@ public void shouldDescriptionEmbeddingProvider() {
// ("db describe-embedding-provider %s --embedding-provider %s"
// .formatted(DB_TEST_VECTOR, "invalid")));

assertSuccessCli("db describe-embedding-provider %s --embedding-provider %s --output json"
assertSuccessCli("help db describe-embedding-provider");

assertSuccessCli("db describe-embedding-provider %s --embedding-provider %s"
.formatted(DB_TEST_VECTOR, "openai"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static void should_create_when_needed() {
assertSuccessCli("db create %s --if-not-exist --vector".formatted(DB_TEST_VECTOR));
}


@Test
@Order(1)
void testShouldShowHelp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void listRegionsTest() {
@Test
void shouldThrowRegionAlreadyExistTest() {
assertExitCodeCli(ALREADY_EXIST, "db create-region %s -r us-east1 -c gcp".formatted(DB_TEST));

}

@Test
Expand Down
Loading

0 comments on commit a7179f7

Please sign in to comment.