Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,005 changes: 1,013 additions & 992 deletions go/internal/proto/console/console.pb.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ message ExecuteCommandRequest {
message ExecuteCommandResponse {
string error_message = 1;
io.deephaven.proto.backplane.grpc.FieldsChangeUpdate changes = 2;
string start_timestamp = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use actual nanos since the epoch than something that needs parsing/interpretation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, I realize that JS sucks at numbers; but the proto is a generic thing. Anytime we add a field, we should also add a comment for the protodocs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have wiring to handle int64 in a format we can get it to js - the following change will make it still be a string in the browser, but we can expose as a DateWrapper so that JS can truncate to number, format to string, or ask for it as a js Date:

Suggested change
string start_timestamp = 3;
int64 start_timestamp = 3 [jstype=JS_STRING];

In theory proto also has a well known date types, but i'd vote just stick to nanos like we do for logs etc
https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/timestamp.proto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified types to the jstype and added a comment

string end_timestamp = 4;
}
message BindTableToVariableRequest {
io.deephaven.proto.backplane.grpc.Ticket console_id = 1;
Expand Down
246 changes: 123 additions & 123 deletions py/client/deephaven_core/proto/console_pb2.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.google.common.base.Throwables;
import com.google.rpc.Code;
import io.deephaven.base.LockFreeArrayQueue;
import io.deephaven.base.clock.Clock;
import io.deephaven.configuration.Configuration;
import io.deephaven.engine.context.ExecutionContext;
import io.deephaven.engine.context.QueryScope;
Expand Down Expand Up @@ -197,6 +198,7 @@ public void executeCommand(

// If not set, we'll use defaults, otherwise we will explicitly set the systemicness.
final ScriptSession.Changes changes;
String startTimestamp = Long.toString(Clock.system().currentTimeNanos());
switch (systemicOption) {
case NOT_SET_SYSTEMIC:
changes = scriptSession.evaluateScript(request.getCode());
Expand All @@ -213,6 +215,7 @@ public void executeCommand(
throw new UnsupportedOperationException(
"Unrecognized systemic option: " + systemicOption);
}
String endTimestamp = Long.toString(Clock.system().currentTimeNanos());

final ExecuteCommandResponse.Builder diff = ExecuteCommandResponse.newBuilder();
final FieldsChangeUpdate.Builder fieldChanges = FieldsChangeUpdate.newBuilder();
Expand All @@ -226,7 +229,11 @@ public void executeCommand(
diff.setErrorMessage(Throwables.getStackTraceAsString(changes.error));
log.error().append("Error running script: ").append(changes.error).endl();
}
return diff.setChanges(fieldChanges).build();
diff.setChanges(fieldChanges);
diff.setStartTimestamp(startTimestamp);
diff.setEndTimestamp(endTimestamp);

return diff.build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing at all wrong with this style, but can also be a builder style as before:

Suggested change
diff.setChanges(fieldChanges);
diff.setStartTimestamp(startTimestamp);
diff.setEndTimestamp(endTimestamp);
return diff.build();
return diff.setChanges(fieldChanges)
.setStartTimestamp(startTimestamp)
.setEndTimestamp(endTimestamp)
.build();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified back to builder style

});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.vertispan.tsdefs.annotations.TsInterface;
import com.vertispan.tsdefs.annotations.TsName;
import io.deephaven.web.client.api.LongWrapper;
import jsinterop.annotations.JsProperty;

/**
Expand All @@ -15,10 +16,14 @@
public class JsCommandResult {
private final JsVariableChanges changes;
private final String error;
private final String startTimestamp;
private final String endTimestamp;

public JsCommandResult(JsVariableChanges changes, String error) {
public JsCommandResult(JsVariableChanges changes, String error, String startTimestamp, String endTimestamp) {
this.changes = changes;
this.error = error;
this.startTimestamp = startTimestamp;
this.endTimestamp = endTimestamp;
}

/**
Expand All @@ -41,6 +46,26 @@ public String getError() {
return error;
}

/**
* The timestamp when the command started running.
*
* @return long
*/
@JsProperty
public LongWrapper getStartTimestamp() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably DateWrapper instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to DateWrapper

return LongWrapper.of(Long.parseLong(startTimestamp));
}

/**
* The timestamp when the command finished running.
*
* @return long
*/
@JsProperty
public LongWrapper getEndTimestamp() {
return LongWrapper.of(Long.parseLong(endTimestamp));
}

@Override
public String toString() {
if (error != null && !error.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,12 @@ public CancellablePromise<JsCommandResult> runCode(String code) {
});
runCodePromise.then(response -> {
JsVariableChanges changes = JsVariableChanges.from(response.getChanges());
final String startTimestamp = response.getStartTimestamp();
final String endTimestamp = response.getEndTimestamp();
if (response.getErrorMessage() == null || response.getErrorMessage().isEmpty()) {
promise.succeed(new JsCommandResult(changes, null));
promise.succeed(new JsCommandResult(changes, null, startTimestamp, endTimestamp));
} else {
promise.succeed(new JsCommandResult(changes, response.getErrorMessage()));
promise.succeed(new JsCommandResult(changes, response.getErrorMessage(), startTimestamp, endTimestamp));
}
return null;
}, err -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ public static native ExecuteCommandResponse.ToObjectReturnType toObject(

public native void setErrorMessage(String value);

public native String getStartTimestamp();

public native String getEndTimestamp();

public native ExecuteCommandResponse.ToObjectReturnType0 toObject();

public native ExecuteCommandResponse.ToObjectReturnType0 toObject(boolean includeInstance);
Expand Down
Loading