@@ -441,18 +441,8 @@ function connect_repl(host=Sockets.localhost, port::Integer=DEFAULT_PORT;
441441 namespace:: Union{AbstractString,Nothing} = nothing ,
442442 startup_text:: Bool = true ,
443443 repl= Base. active_repl)
444- global _repl_client_connection
445-
446- if ! isnothing (_repl_client_connection)
447- try
448- close (_repl_client_connection)
449- catch exc
450- @warn " Exception closing connection" exception= (exc,catch_backtrace ())
451- end
452- end
453444
454- conn = Connection (host= host, port= port, tunnel= tunnel,
455- ssh_opts= ssh_opts, region= region, namespace= namespace)
445+ conn = connect_remote (host, port; tunnel, ssh_opts, region,namespace)
456446 out_stream = stdout
457447 prompt = ReplMaker. initrepl (c-> run_remote_repl_command (conn, out_stream, c),
458448 repl = Base. active_repl,
@@ -465,13 +455,43 @@ function connect_repl(host=Sockets.localhost, port::Integer=DEFAULT_PORT;
465455 completion_provider = RemoteCompletionProvider (conn),
466456 startup_text = startup_text
467457 )
468- # Record the connection which is attached to the REPL
469- _repl_client_connection = conn
470458 prompt
471459end
472460
473461connect_repl (port:: Integer ) = connect_repl (Sockets. localhost, port)
474462
463+ """
464+ connect_remote([host=localhost,] port::Integer=$DEFAULT_PORT ;
465+ tunnel = (host != localhost) ? :ssh : :none,
466+ ssh_opts = ``)
467+
468+ Connect to remote server without any REPL integrations. This will allow you to use `@remote`, but not the REPL mode.
469+ Useful in circumstances where no REPL is available, but interactivity is desired like Jupyter or Pluto notebooks.
470+ Otherwise, see `connect_repl`.
471+ """
472+ function connect_remote (host= Sockets. localhost, port:: Integer = DEFAULT_PORT;
473+ tunnel:: Symbol = host!= Sockets. localhost ? :ssh : :none ,
474+ ssh_opts:: Cmd = ` ` ,
475+ region:: Union{AbstractString,Nothing} = nothing ,
476+ namespace:: Union{AbstractString,Nothing} = nothing )
477+
478+ global _repl_client_connection
479+
480+ if ! isnothing (_repl_client_connection)
481+ try
482+ close (_repl_client_connection)
483+ catch exc
484+ @warn " Exception closing connection" exception= (exc,catch_backtrace ())
485+ end
486+ end
487+ conn = RemoteREPL. Connection (host= host, port= port, tunnel= tunnel,
488+ ssh_opts= ssh_opts, region= region, namespace= namespace)
489+
490+ # Record the connection in a global variable so it's accessible to REPL and `@remote`
491+ _repl_client_connection = conn
492+ end
493+
494+
475495"""
476496 @remote ex
477497
0 commit comments