Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectType and Plugins #1787

Merged
merged 67 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
a24ec60
ObjectType and Plugins
devinrsmith Dec 30, 2021
ecf7e80
Remove old custom type name
devinrsmith Dec 30, 2021
91bd98a
Fix python integration tests
devinrsmith Dec 30, 2021
74aec62
Move logic into deephaven.server.plugin
devinrsmith Dec 31, 2021
ebda9d1
spotless
devinrsmith Dec 31, 2021
968ec24
Move deephaven.server into deephaven2.server so fix broken integratio…
devinrsmith Jan 1, 2022
bb638e6
Review responses
devinrsmith Jan 4, 2022
fe8414f
f
devinrsmith Jan 5, 2022
e4da7bb
f
devinrsmith Jan 5, 2022
8ee1947
better dagger and docs
devinrsmith Jan 6, 2022
354a5a7
f
devinrsmith Jan 6, 2022
edc0617
f
devinrsmith Jan 6, 2022
ca1875d
Merge remote-tracking branch 'upstream/main' into fetch-object
devinrsmith Jan 6, 2022
781cbf2
Stuff
devinrsmith Jan 6, 2022
9de9a46
remove test from dockerfile
devinrsmith Jan 6, 2022
44bec3b
wrong cast
devinrsmith Jan 7, 2022
18b66c1
Revert "remove test from dockerfile"
devinrsmith Jan 7, 2022
a2dc389
Add ObjectServiceTest
devinrsmith Jan 7, 2022
2881aff
Fix plugin discovery for unit tests
devinrsmith Jan 7, 2022
aa89bad
Refactor into Plugin interface which can be walked
devinrsmith Jan 10, 2022
965337b
Fix python, remove png
devinrsmith Jan 10, 2022
e12c2f8
Ryan's suggestions
devinrsmith Jan 10, 2022
f66297a
Remove matplotlib plugin installation
devinrsmith Jan 10, 2022
5e593e6
Merge remote-tracking branch 'upstream/main' into fetch-object
devinrsmith Jan 10, 2022
7dbc3b0
Implement support for the ABC released deephaven-plugin.
devinrsmith Jan 10, 2022
de91510
remove old comment
devinrsmith Jan 11, 2022
49577a0
Use python native array, not java byte array
devinrsmith Jan 11, 2022
3f0e0df
Ensure that python native objects can be exported
devinrsmith Nov 1, 2021
8d3b2e1
Rename
devinrsmith Jan 11, 2022
45970fd
recursive fetch
devinrsmith Jan 11, 2022
2941ea9
Add init method
devinrsmith Jan 12, 2022
5804556
Fix reference id bytes
devinrsmith Jan 12, 2022
b0afabf
Cleanup and consolidate to TypedTicket
devinrsmith Jan 12, 2022
14452e2
auto service
devinrsmith Jan 13, 2022
7265104
f
devinrsmith Jan 13, 2022
ce855b9
Typing and Reference stuff
devinrsmith Jan 13, 2022
88d1686
Merge remote-tracking branch 'upstream/main' into fetch-object
devinrsmith Jan 13, 2022
a7fc020
Remove FetchFigure
devinrsmith Jan 13, 2022
d905b37
Update generated gwt bindings, new code doesn't work in api yet
niloc132 Jan 14, 2022
e342fe1
Updated Exporter interface to allow caller to be more explicit about …
devinrsmith Jan 14, 2022
5c3beb2
Update console js layer
devinrsmith Jan 14, 2022
7576357
fix test
devinrsmith Jan 14, 2022
8f4e8e3
TypedTicket has Ticket
devinrsmith Jan 14, 2022
9032e66
Use empty string instead of optional
devinrsmith Jan 14, 2022
366151c
Fix js vars, and plumb object service for figures
niloc132 Jan 18, 2022
7bbf573
CHERRY-PICK always set an errorId
niloc132 Jan 18, 2022
30e92c2
Figure shouldn't try to re-export, clean up console vars
niloc132 Jan 18, 2022
01c93e3
Verify CTS gets a sane handle
niloc132 Jan 18, 2022
1dd9a59
More test coverage
devinrsmith Jan 18, 2022
17eea96
Added "typed_" prefix. Fixed FieldInfo.
devinrsmith Jan 19, 2022
21a6185
Merge remote-tracking branch 'dsmith/fetch-object' into fetch-object-js
niloc132 Jan 19, 2022
4009b93
Update generated gwt bindings
niloc132 Jan 19, 2022
7681a3f
Update to new typedticket stuff
niloc132 Jan 19, 2022
fe57ee7
spotless
devinrsmith Jan 20, 2022
eb9863c
Copy regenerated _pb2
devinrsmith Jan 20, 2022
1811bb3
Final fixes
devinrsmith Jan 21, 2022
33cf3d2
Merge remote-tracking branch 'upstream/main' into fetch-object
devinrsmith Jan 21, 2022
b298d47
plumb TypedTicket
devinrsmith Jan 21, 2022
cf36e5b
regen and copy python proto
devinrsmith Jan 21, 2022
e492010
Update test
devinrsmith Jan 21, 2022
95ada5c
Update gwt bindings
niloc132 Jan 21, 2022
15296cb
Update JS API to use typedticket for object fetch
niloc132 Jan 21, 2022
d28c82d
Remove Reference.ticket
devinrsmith Jan 21, 2022
a995b11
fix python side for Reference
devinrsmith Jan 21, 2022
d736c85
FetchObject client don't try Table. Better exceptions for FetchObject
devinrsmith Jan 24, 2022
580b272
Add reference to #1872
devinrsmith Jan 24, 2022
ddfcdaa
add because notes for api dagger dependencies
devinrsmith Jan 24, 2022
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
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Set<Project> modsAreBasic = subprojects.findAll {it.name in [
'docker-runtime-base',
'docker-server',
'docker-server-slim',
'raw-js-openapi'
'raw-js-openapi',
] }

Set<Project> modsAreBin = subprojects.findAll {it.name in ['bin', 'configs', 'test-configs'] }
Expand Down Expand Up @@ -397,6 +397,8 @@ tasks.register 'allJavadoc', Javadoc, {
':extensions-csv',
':extensions-kafka',
':extensions-parquet-table',
':plugin',
':plugin-figure',
':Util',
':ModelFarm',
':Numerics',
Expand Down
3 changes: 0 additions & 3 deletions docker/server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ def prepareDocker = project.tasks.register('prepareDocker', Sync) {
into server
}
}
from ('src/main/arch') {
into 'arch'
}
from ('src/main/configure') {
into 'configure'
}
Expand Down
2 changes: 2 additions & 0 deletions engine/table/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ dependencies {
"org.eclipse.jgit:org.eclipse.jgit:$Classpaths.JGIT_VERSION",
'com.tdunning:t-digest:3.2'

implementation project(':plugin')

Classpaths.inheritGroovy(project, 'groovy', 'implementation')
Classpaths.inheritGroovy(project, 'groovy-json', 'implementation')
Classpaths.inheritJavaParser project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,38 @@
import io.deephaven.api.util.NameValidator;
import io.deephaven.base.FileUtils;
import io.deephaven.compilertools.CompilerTools;
import io.deephaven.engine.liveness.LivenessScope;
import io.deephaven.engine.liveness.LivenessScopeStack;
import io.deephaven.engine.table.Table;
import io.deephaven.engine.table.TableDefinition;
import io.deephaven.engine.table.TableMap;
import io.deephaven.engine.table.lang.QueryLibrary;
import io.deephaven.engine.table.lang.QueryScopeParam;
import io.deephaven.engine.table.lang.QueryScope;
import io.deephaven.engine.liveness.LivenessScope;
import io.deephaven.engine.liveness.LivenessScopeStack;
import io.deephaven.engine.table.lang.QueryScopeParam;
import io.deephaven.engine.util.AbstractScriptSession.Snapshot;
import io.deephaven.plugin.type.ObjectType;
import io.deephaven.plugin.type.ObjectTypeLookup;
import io.deephaven.util.SafeCloseable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.*;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

import static io.deephaven.engine.table.Table.HIERARCHICAL_CHILDREN_TABLE_MAP_ATTRIBUTE;
import static io.deephaven.engine.table.Table.NON_DISPLAY_TABLE;

/**
* This class exists to make all script sessions to be liveness artifacts, and provide a default implementation for
* evaluateScript which handles liveness and diffs in a consistent way.
*/
public abstract class AbstractScriptSession extends LivenessScope implements ScriptSession, VariableProvider {
public abstract class AbstractScriptSession<S extends Snapshot> extends LivenessScope
implements ScriptSession, VariableProvider {

private static final Path CLASS_CACHE_LOCATION = CacheDir.get().resolve("script-session-classes");

Expand All @@ -54,9 +65,12 @@ private static void createOrClearDirectory(final File directory) {
protected final QueryLibrary queryLibrary;
protected final CompilerTools.Context compilerContext;

private final ObjectTypeLookup objectTypeLookup;
private final Listener changeListener;

protected AbstractScriptSession(@Nullable Listener changeListener, boolean isDefaultScriptSession) {
protected AbstractScriptSession(ObjectTypeLookup objectTypeLookup, @Nullable Listener changeListener,
boolean isDefaultScriptSession) {
this.objectTypeLookup = objectTypeLookup;
this.changeListener = changeListener;

// TODO(deephaven-core#1713): Introduce instance-id concept
Expand Down Expand Up @@ -90,10 +104,32 @@ public String getClassPath() {
}
}

protected synchronized void publishInitial() {
applyDiff(emptySnapshot(), takeSnapshot(), null);
}

interface Snapshot {

}

protected abstract S emptySnapshot();

protected abstract S takeSnapshot();

protected abstract Changes createDiff(S from, S to, RuntimeException e);

protected Changes applyDiff(S from, S to, RuntimeException e) {
final Changes diff = createDiff(from, to, e);
if (changeListener != null) {
changeListener.onScopeChanges(this, diff);
}
return diff;
}

@Override
public synchronized final Changes evaluateScript(final String script, final @Nullable String scriptName) {
final Changes diff = new Changes();
final Map<String, Object> existingScope = new HashMap<>(getVariables());
RuntimeException evaluateErr = null;
final S fromSnapshot = takeSnapshot();

// store pointers to exist query scope static variables
final QueryLibrary prevQueryLibrary = QueryLibrary.getLibrary();
Expand All @@ -110,71 +146,79 @@ public synchronized final Changes evaluateScript(final String script, final @Nul
// actually evaluate the script
evaluate(script, scriptName);
} catch (final RuntimeException err) {
diff.error = err;
evaluateErr = err;
} finally {
// restore pointers to query scope static variables
QueryScope.setScope(prevQueryScope);
CompilerTools.setContext(prevCompilerContext);
QueryLibrary.setLibrary(prevQueryLibrary);
}

final Map<String, Object> newScope = new HashMap<>(getVariables());
final S toSnapshot = takeSnapshot();

// produce a diff
for (final Map.Entry<String, Object> entry : newScope.entrySet()) {
final String name = entry.getKey();
final Object existingValue = existingScope.get(name);
final Object newValue = entry.getValue();
applyVariableChangeToDiff(diff, name, existingValue, newValue);
}

for (final Map.Entry<String, Object> entry : existingScope.entrySet()) {
final String name = entry.getKey();
if (newScope.containsKey(name)) {
continue; // this is already handled even if old or new values are non-displayable
}
applyVariableChangeToDiff(diff, name, entry.getValue(), null);
}

if (changeListener != null && !diff.isEmpty()) {
changeListener.onScopeChanges(this, diff);
}
final Changes diff = applyDiff(fromSnapshot, toSnapshot, evaluateErr);

// re-throw any captured exception now that our listener knows what query scope state had changed prior
// to the script session execution error
if (diff.error != null) {
throw diff.error;
if (evaluateErr != null) {
throw evaluateErr;
}

return diff;
}

private void applyVariableChangeToDiff(final Changes diff, String name,
protected void applyVariableChangeToDiff(final Changes diff, String name,
@Nullable Object fromValue, @Nullable Object toValue) {
fromValue = unwrapObject(fromValue);
final ExportedObjectType fromType = ExportedObjectType.fromObject(fromValue);
if (!fromType.isDisplayable()) {
if (fromValue == toValue) {
return;
}
final String fromTypeName = getTypeNameIfDisplayable(fromValue).orElse(null);
if (fromTypeName == null) {
fromValue = null;
}
toValue = unwrapObject(toValue);
final ExportedObjectType toType = ExportedObjectType.fromObject(toValue);
if (!toType.isDisplayable()) {
final String toTypeName = getTypeNameIfDisplayable(toValue).orElse(null);
if (toTypeName == null) {
toValue = null;
}
if (fromValue == toValue) {
return;
}

if (fromValue == null) {
diff.created.put(name, toType);
} else if (toValue == null) {
diff.removed.put(name, fromType);
} else if (fromType != toType) {
diff.created.put(name, toType);
diff.removed.put(name, fromType);
} else {
diff.updated.put(name, toType);
diff.created.put(name, toTypeName);
return;
}
if (toValue == null) {
diff.removed.put(name, fromTypeName);
return;
}
if (!fromTypeName.equals(toTypeName)) {
diff.created.put(name, toTypeName);
diff.removed.put(name, fromTypeName);
return;
}
diff.updated.put(name, toTypeName);
}

private Optional<String> getTypeNameIfDisplayable(Object object) {
if (object == null) {
return Optional.empty();
}
if (object instanceof Table) {
final Table table = (Table) object;
if (table.hasAttribute(NON_DISPLAY_TABLE)) {
return Optional.empty();
}
if (table.hasAttribute(HIERARCHICAL_CHILDREN_TABLE_MAP_ATTRIBUTE)) {
return Optional.of("TreeTable");
}
return Optional.of("Table");
}
if (object instanceof TableMap) {
return Optional.empty();
// TODO(deephaven-core#1762): Implement Smart-Keys and Table-Maps
// return Optional.of("TableMap");
devinrsmith marked this conversation as resolved.
Show resolved Hide resolved
}
return objectTypeLookup.findObjectType(object).map(ObjectType::name);
}

@Override
Expand All @@ -193,7 +237,6 @@ protected synchronized void notifyVariableChange(String name, @Nullable Object o
if (changeListener == null) {
return;
}

Changes changes = new Changes();
applyVariableChangeToDiff(changes, name, oldValue, newValue);
if (!changes.isEmpty()) {
Expand Down

This file was deleted.

Loading