Skip to content

Commit

Permalink
Minor code and formatting adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
vogti committed Aug 26, 2023
1 parent 05d20c2 commit 113eec5
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 49 deletions.
4 changes: 1 addition & 3 deletions plugins/jupyter-integration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ dependencies {
exclude(group: "org.slf4j")
}


implementation group: "net.sf.opencsv", name: "opencsv", version: opencsv_version // Apache 2.0
implementation group: "commons-io", name: "commons-io", version: commons_io_version // Apache 2.0


// --- Test Compile ---
testImplementation project(path: ":dbms", configuration: "test")
testImplementation project(path: ":core", configuration: "tests")
Expand Down Expand Up @@ -89,5 +89,3 @@ java {
licensee {
allow('Apache-2.0')
}


Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,4 @@ private void error( Context ctx, int code, String message ) {
ctx.result( String.format( "{\"message\": %s, \"reason\": null}", gson.toJson( message ) ) );
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.Objects;
import java.util.Optional;
import java.util.regex.Pattern;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.calcite.avatica.util.Base64;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
package org.polypheny.db.jupyter;

import io.javalin.http.Context;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand All @@ -43,9 +44,6 @@
import org.polypheny.db.webui.HttpServer;
import org.polypheny.db.webui.HttpServer.HandlerType;

import java.security.SecureRandom;
import java.util.Arrays;

@Slf4j
public class JupyterPlugin extends Plugin {

Expand Down Expand Up @@ -150,18 +148,17 @@ private boolean createContainer( DockerInstance dockerInstance ) {

if ( !this.container.waitTillStarted( this::testConnection, 20000 ) ) {
this.container.destroy();
throw new RuntimeException( "Failed to start jupyter container" );
throw new RuntimeException( "Failed to start Jupyter Server container" );
}
ConfigManager.getInstance().getConfig( CONFIG_CONTAINER_KEY ).setString( this.container.getContainerId() );
log.info( "Jupyter container has been deployed." );
log.info( "Jupyter Server container has been deployed" );
} else {
this.container = maybeContainer.get();
}
onContainerRunning();
return true;
} catch ( Exception e ) {
e.printStackTrace();
log.warn( "Unable to deploy Jupyter container." );
log.warn( "Unable to deploy Jupyter Server container", e );
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package org.polypheny.db.jupyter;

import com.google.gson.Gson;
import io.javalin.http.Context;
import java.net.http.HttpResponse;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.jupyter.JupyterClient.JupyterServerException;
import org.polypheny.db.jupyter.model.JupyterSessionManager;
import io.javalin.http.Context;

@Slf4j
public class JupyterProxy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ public void execute( String code, String uuid ) {
* @param variable the name of the variable the result will be stored in
* @param expandParams whether to expand variables specified in the form ${varname}
*/
public void executePolyCell( String query, String uuid, String language, String namespace,
public void executePolyCell(
String query, String uuid, String language, String namespace,
String variable, boolean expandParams ) {
if ( query.strip().length() == 0 ) {
if ( query.strip().isEmpty() ) {
execute( "", uuid ); // properly terminates the request
return;
}
Expand All @@ -230,7 +231,7 @@ public void executePolyCell( String query, String uuid, String language, String
webSocket.sendBinary( request, true );
}
} catch ( Exception e ) {
e.printStackTrace();
log.error( "Exception while executing a Polypheny Notebook cell.", e );
}

}
Expand Down Expand Up @@ -412,7 +413,7 @@ public CompletionStage<?> onClose( WebSocket webSocket, int statusCode, String r

@Override
public void onError( WebSocket webSocket, Throwable error ) {
error.printStackTrace();
log.error( "Exception in Jupyter WebSocket.", error );
jsm.removeKernel( kernelId );
Listener.super.onError( webSocket, error );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ public JupyterQueryPart( String code, boolean silent, boolean allowStdin ) {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

@Getter
public class ContentsCreateRequest {
@SerializedName( "copy_from" )

@SerializedName("copy_from")
private String copyFrom;
private String ext;
private String type;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,28 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* See https://jupyter-server.readthedocs.io/en/latest/developers/rest-api.html
*/
@NoArgsConstructor
public class NotebookContentModel {
// see https://jupyter-server.readthedocs.io/en/latest/developers/rest-api.html

@Getter
private String name, path, created, format, mimetype, size, writable, type;
private String name;
@Getter
private String path;
@Getter
private String created;
@Getter
private String format;
@Getter
private String mimetype;
@Getter
private String size;
@Getter
private String writable;
@Getter
private String type;

@Getter
@SerializedName("last_modified")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import lombok.Setter;
import org.polypheny.db.jupyter.model.language.JupyterKernelLanguage;

/**
* See https://nbformat.readthedocs.io/en/latest/format_description.html
*/
@NoArgsConstructor
public class NotebookModel {
// see https://nbformat.readthedocs.io/en/latest/format_description.html

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public class PolyMetadataModel {
private String cellType;

@Getter
private String namespace, language;
private String namespace;

@Getter
private String language;

@Getter
@SerializedName("result_variable")
Expand Down

This file was deleted.

0 comments on commit 113eec5

Please sign in to comment.