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

Log User-Friendly Error When AutoComplete is not Available #4316

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.google.rpc.Code;
import io.deephaven.base.LockFreeArrayQueue;
import io.deephaven.configuration.Configuration;
import io.deephaven.engine.context.QueryScope;
import io.deephaven.engine.table.Table;
import io.deephaven.engine.table.impl.perf.QueryPerformanceNugget;
import io.deephaven.engine.table.impl.perf.QueryPerformanceRecorder;
Expand Down Expand Up @@ -61,8 +62,10 @@ public class ConsoleServiceGrpcImpl extends ConsoleServiceGrpc.ConsoleServiceImp
public static final boolean REMOTE_CONSOLE_DISABLED =
Configuration.getInstance().getBooleanWithDefault("deephaven.console.disable", false);

private static final String DISABLE_AUTOCOMPLETE_FLAG = "deephaven.console.autocomplete.disable";
public static final boolean AUTOCOMPLETE_DISABLED =
Configuration.getInstance().getBooleanWithDefault("deephaven.console.autocomplete.disable", false);
Configuration.getInstance().getBooleanWithDefault(DISABLE_AUTOCOMPLETE_FLAG, false);


public static final boolean QUIET_AUTOCOMPLETE_ERRORS =
Configuration.getInstance().getBooleanWithDefault("deephaven.console.autocomplete.quiet", true);
Expand All @@ -75,6 +78,8 @@ public class ConsoleServiceGrpcImpl extends ConsoleServiceGrpc.ConsoleServiceImp
public static final int SUBSCRIBE_TO_LOGS_BUFFER_SIZE =
Configuration.getInstance().getIntegerWithDefault(SUBSCRIBE_TO_LOGS_BUFFER_SIZE_PROP, 32768);

private static final AtomicBoolean ALREADY_WARNED_ABOUT_NO_AUTOCOMPLETE = new AtomicBoolean();

private final TicketRouter ticketRouter;
private final SessionService sessionService;
private final Provider<ScriptSession> scriptSessionProvider;
Expand Down Expand Up @@ -296,7 +301,7 @@ public void bindTableToVariable(
public StreamObserver<AutoCompleteRequest> autoCompleteStream(
@NotNull final StreamObserver<AutoCompleteResponse> responseObserver) {
final SessionState session = sessionService.getCurrentSession();
if (AUTOCOMPLETE_DISABLED) {
if (AUTOCOMPLETE_DISABLED || ALREADY_WARNED_ABOUT_NO_AUTOCOMPLETE.get()) {
return new NoopAutoCompleteObserver(session, responseObserver);
}
if (PythonDeephavenSession.SCRIPT_TYPE.equals(scriptSessionProvider.get().scriptType())) {
Expand All @@ -307,7 +312,13 @@ public StreamObserver<AutoCompleteRequest> autoCompleteStream(
"from deephaven_internal.auto_completer import jedi_settings ; jedi_settings.set_scope(globals())");
settings[0] = (PyObject) scriptSession.getVariable("jedi_settings");
} catch (Exception err) {
log.error().append("Error trying to enable jedi autocomplete").append(err).endl();
if (!ALREADY_WARNED_ABOUT_NO_AUTOCOMPLETE.getAndSet(true)) {
log.error().append("Autocomplete package not found; disabling autocomplete.").endl();
log.error().append("Do you need to install the autocomplete package?").endl();
log.error().append(" pip install deephaven-core[autocomplete]==<version>").endl();
log.error().append("Add the jvm flag '-D").append(DISABLE_AUTOCOMPLETE_FLAG)
.append("=true' to disable this message.").endl();
}
}
boolean canJedi = settings[0] != null && settings[0].call("can_jedi").getBooleanValue();
log.info().append(canJedi ? "Using jedi for python autocomplete"
Expand Down
Loading