Skip to content

Commit

Permalink
- fixed CLI flags - updated Readme - updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hkuich committed Feb 19, 2021
1 parent 536704b commit e5bb062
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ Once your configuration files are complete, you can use GraMi in one of two ways

```Shell
./bin/grami migrate \
-d /path/to/dataConfig.json \
-p /path/to/processorConfig.json \
-m /path/to/migrationStatus.json \
-dc /path/to/dataConfig.json \
-pc /path/to/processorConfig.json \
-ms /path/to/migrationStatus.json \
-s /path/to/schema.gql \
-k yourFavoriteKeyspace \
-cm
-db yourFavoriteDatabase
```

[See details here](https://github.com/bayer-science-for-a-better-life/grami/wiki/Grami-as-Executable-CLI)
Expand All @@ -99,9 +98,9 @@ public class Migration {
private static final String migrationStatus = "/path/to/your/migrationStatus.json";

private static final String graknURI = "127.0.0.1:1729"; // defines which grakn server to migrate into
private static final String keyspaceName = "yourFavoriteKeyspace"; // defines which keyspace to migrate into
private static final String databaseName = "yourFavoriteDatabase"; // defines which keyspace to migrate into

private static final MigrationConfig migrationConfig = new MigrationConfig(graknURI, keyspaceName, schema, dataConfig, processorConfig);
private static final MigrationConfig migrationConfig = new MigrationConfig(graknURI, databaseName, schema, dataConfig, processorConfig);

public static void main(String[] args) throws IOException {
GraknMigrator mig = new GraknMigrator(migrationConfig, migrationStatus, true);
Expand All @@ -119,6 +118,8 @@ A complete tutorial for grakn version >= 2.0 is in work and will be published as

A complete tutorial for grakn version >= 1.8.2, but < 2.0 can be found [on Medium](https://medium.com/@hkuich/introducing-grami-a-data-migration-tool-for-grakn-d4051582f867).

There is this [example repository](https://github.com/bayer-science-for-a-better-life/grami-example).

## Compatibility

GraMi version >= 0.1.0 is tested for:
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/cli/GramiCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.io.IOException;

@CommandLine.Command(description="Welcome to the CLI of GraMi - your grakn data migration tool", name = "grami", version = "0.1.0", mixinStandardHelpOptions = true)
@CommandLine.Command(description="Welcome to the CLI of GraMi - your grakn data migration tool", name = "grami", version = "0.1.0-alpha-9", mixinStandardHelpOptions = true)
public class GramiCLI {

public static void main(String[] args) {
Expand All @@ -25,20 +25,20 @@ public static void main(String[] args) {
class MigrateCommand implements Runnable {
@CommandLine.Spec CommandLine.Model.CommandSpec spec;

@CommandLine.Option(names = {"-d", "--dataConfigFile"}, description = "data config file in JSON format", required = true)
@CommandLine.Option(names = {"-dc", "--dataConfigFile"}, description = "data config file in JSON format", required = true)
private String dataConfigFilePath;

@CommandLine.Option(names = {"-p", "--processorConfigFile"}, description = "processor config file in JSON format", required = true)
@CommandLine.Option(names = {"-pc", "--processorConfigFile"}, description = "processor config file in JSON format", required = true)
private String processorConfigFilePath;

@CommandLine.Option(names = {"-m", "--migrationStatusFile"}, description = "file to track migration status in", required = true)
@CommandLine.Option(names = {"-ms", "--migrationStatusFile"}, description = "file to track migration status in", required = true)
private String migrationStatusFilePath;

@CommandLine.Option(names = {"-s", "--schemaFile"}, description = "your schema file as .gql", required = true)
private String schemaFilePath;

@CommandLine.Option(names = {"-k", "--keyspace"}, description = "target keyspace in your grakn instance", required = true)
private String keyspaceName;
@CommandLine.Option(names = {"-db", "--database"}, description = "target database in your grakn instance", required = true)
private String databaseName;

@CommandLine.Option(names = {"-g", "--grakn"}, description = "optional - grakn DB in format: server:port (default: localhost:1729)", defaultValue = "localhost:1729")
private String graknURI;
Expand All @@ -57,12 +57,12 @@ public void run() {
spec.commandLine().getOut().println("\tprocessor configuration: " + processorConfigFilePath);
spec.commandLine().getOut().println("\ttracking migration status in: " + migrationStatusFilePath);
spec.commandLine().getOut().println("\tschema: " + schemaFilePath);
spec.commandLine().getOut().println("\tkeyspace: " + keyspaceName);
spec.commandLine().getOut().println("\tdatabase: " + databaseName);
spec.commandLine().getOut().println("\tgrakn server: " + graknURI);
spec.commandLine().getOut().println("\tdelete keyspace and all data in it for a clean new migration?: " + cleanMigration);
spec.commandLine().getOut().println("\tdelete database and all data in it for a clean new migration?: " + cleanMigration);
spec.commandLine().getOut().println("\tmigration scope: " + scope);

final MigrationConfig migrationConfig = new MigrationConfig(graknURI, keyspaceName, schemaFilePath, dataConfigFilePath, processorConfigFilePath);
final MigrationConfig migrationConfig = new MigrationConfig(graknURI, databaseName, schemaFilePath, dataConfigFilePath, processorConfigFilePath);

try {
GraknMigrator mig = new GraknMigrator(migrationConfig, migrationStatusFilePath, cleanMigration);
Expand Down Expand Up @@ -91,21 +91,21 @@ class SchemaUpdateCommand implements Runnable {
@CommandLine.Option(names = {"-s", "--schemaFile"}, description = "your schema file as .gql", required = true)
private String schemaFilePath;

@CommandLine.Option(names = {"-k", "--keyspace"}, description = "target keyspace in your grakn instance", required = true)
private String keyspaceName;
@CommandLine.Option(names = {"-db", "--database"}, description = "target database in your grakn instance", required = true)
private String databaseName;

@CommandLine.Option(names = {"-g", "--grakn"}, description = "optional - grakn DB in format: server:port (default: localhost:48555)", defaultValue = "localhost:48555")
@CommandLine.Option(names = {"-g", "--grakn"}, description = "optional - grakn DB in format: server:port (default: localhost:1729)", defaultValue = "localhost:1729")
private String graknURI;

@Override
public void run() {
spec.commandLine().getOut().println("############## GraMi schema-update ###############");
spec.commandLine().getOut().println("schema-update started with parameters:");
spec.commandLine().getOut().println("\tschema: " + schemaFilePath);
spec.commandLine().getOut().println("\tkeyspace: " + keyspaceName);
spec.commandLine().getOut().println("\tkeyspace: " + databaseName);
spec.commandLine().getOut().println("\tgrakn server: " + graknURI);

SchemaUpdateConfig suConfig = new SchemaUpdateConfig(graknURI, keyspaceName, schemaFilePath);
SchemaUpdateConfig suConfig = new SchemaUpdateConfig(graknURI, databaseName, schemaFilePath);
SchemaUpdater su = new SchemaUpdater(suConfig);
su.updateSchema();
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/cli/GramiCLITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class GramiCLITest {
public void migrateTest() {
String[] args = {
"migrate",
"-d", "src/test/resources/phone-calls/dataConfig.json",
"-p", "src/test/resources/phone-calls/processorConfig.json",
"-m", "src/test/resources/phone-calls/migrationStatus.json",
"-dc", "src/test/resources/phone-calls/dataConfig.json",
"-pc", "src/test/resources/phone-calls/processorConfig.json",
"-ms", "src/test/resources/phone-calls/migrationStatus.json",
"-s", "src/test/resources/phone-calls/schema.gql",
"-k", "grami_cli_test",
"-db", "grami_cli_test",
"-g", "127.0.0.1:1729",
"-cm"
};
Expand All @@ -41,7 +41,7 @@ public void updateTest() {
String[] args = {
"schema-update",
"-s", "src/test/resources/phone-calls/schema-updated.gql",
"-k", "grami_cli_test",
"-db", "grami_cli_test",
"-g", "127.0.0.1:1729",
};

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/migrator/MigrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public class MigrationTest {

String graknURI = "localhost:1730";
String graknURI = "localhost:1729";

@Test
public void migrateGenericTestsTest() throws IOException {
Expand Down

0 comments on commit e5bb062

Please sign in to comment.