Skip to content

Commit

Permalink
Move Script Cache Clearing to Dagger (#5436)
Browse files Browse the repository at this point in the history
Also ensure directories before creating temp compilation directory in QueryCompilerImpl.
  • Loading branch information
nbauernfeind authored and stanbrub committed May 3, 2024
1 parent af8847a commit 482388e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -814,13 +814,13 @@ private void maybeCreateClasses(
final String tempDirAsString;
try {
rootPathAsString = getClassDestination().getAbsolutePath();
final Path tempPath =
Files.createTempDirectory(Paths.get(rootPathAsString), "temporaryCompilationDirectory");
tempDirAsString = tempPath.toFile().getAbsolutePath();

for (final CompilationRequestAttempt request : requests) {
request.ensureDirectories(rootPathAsString);
}

final Path tempPath =
Files.createTempDirectory(Paths.get(rootPathAsString), "temporaryCompilationDirectory");
tempDirAsString = tempPath.toFile().getAbsolutePath();
} catch (IOException ioe) {
Exception err = new UncheckedIOException(ioe);
for (final CompilationRequestAttempt request : requests) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.deephaven.server.session.TicketResolver;
import io.grpc.BindableService;

import javax.inject.Singleton;
import java.util.Collections;
import java.util.Set;

Expand All @@ -25,6 +26,12 @@ public interface ConsoleModule {
@IntoSet
TicketResolver bindConsoleTicketResolver(ScopeTicketResolver resolver);

@Provides
@Singleton
static ScriptSessionCacheInit bindScriptSessionCacheInit() {
return new ScriptSessionCacheInit();
}

@Provides
@ElementsIntoSet
static Set<CustomCompletion.Factory> primeCustomCompletions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ ScriptSession bindScriptSession(NoLanguageDeephavenSession noLanguageSession) {
@Provides
NoLanguageDeephavenSession bindNoLanguageSession(
@Named(PeriodicUpdateGraph.DEFAULT_UPDATE_GRAPH_NAME) final UpdateGraph updateGraph,
final OperationInitializer operationInitializer) {
final OperationInitializer operationInitializer,
final ScriptSessionCacheInit ignored) {
return new NoLanguageDeephavenSession(updateGraph, operationInitializer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.server.console;

import io.deephaven.engine.util.AbstractScriptSession;

import javax.inject.Inject;
import javax.inject.Singleton;

@Singleton
public class ScriptSessionCacheInit {

@Inject
public ScriptSessionCacheInit() {
// create the script cache (or clear previous sessions)
AbstractScriptSession.createScriptCache();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.deephaven.engine.util.GroovyDeephavenSession.RunScripts;
import io.deephaven.engine.util.ScriptSession;
import io.deephaven.plugin.type.ObjectTypeLookup;
import io.deephaven.server.console.ScriptSessionCacheInit;

import javax.inject.Named;
import java.io.IOException;
Expand All @@ -34,7 +35,8 @@ GroovyDeephavenSession bindGroovySession(
final OperationInitializer operationInitializer,
final ObjectTypeLookup lookup,
final ScriptSession.Listener listener,
final RunScripts runScripts) {
final RunScripts runScripts,
final ScriptSessionCacheInit ignored) {
try {
return GroovyDeephavenSession.of(updateGraph, operationInitializer, lookup, listener, runScripts);
} catch (final IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.deephaven.engine.util.ScriptSession;
import io.deephaven.integrations.python.PythonDeephavenSession;
import io.deephaven.plugin.type.ObjectTypeLookup;
import io.deephaven.server.console.ScriptSessionCacheInit;
import io.deephaven.util.thread.ThreadInitializationFactory;

import javax.inject.Named;
Expand All @@ -36,7 +37,8 @@ PythonDeephavenSession bindPythonSession(
final OperationInitializer operationInitializer,
final ObjectTypeLookup lookup,
final ScriptSession.Listener listener,
final PythonEvaluatorJpy pythonEvaluator) {
final PythonEvaluatorJpy pythonEvaluator,
final ScriptSessionCacheInit ignored) {
try {
return new PythonDeephavenSession(
updateGraph, operationInitializer, threadInitializationFactory, lookup, listener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ public DeephavenApiServer run() throws IOException, ClassNotFoundException, Time
log.info().append("Configuring logging...").endl();
logInit.run();

log.info().append("Creating/Clearing Script Cache...").endl();
AbstractScriptSession.createScriptCache();

for (BusinessCalendar calendar : calendars.get()) {
Calendars.addCalendar(calendar);
}
Expand Down

0 comments on commit 482388e

Please sign in to comment.