Starts a remote JupyterLab server to allow the user to connect to the codespace via JupyterLab in their browser
(ctx context.Context)
| 167 | |
| 168 | // Starts a remote JupyterLab server to allow the user to connect to the codespace via JupyterLab in their browser |
| 169 | func (i *invoker) StartJupyterServer(ctx context.Context) (port int, serverUrl string, err error) { |
| 170 | ctx = i.appendMetadata(ctx) |
| 171 | ctx, cancel := context.WithTimeout(ctx, requestTimeout) |
| 172 | defer cancel() |
| 173 | |
| 174 | response, err := i.jupyterClient.GetRunningServer(ctx, &jupyter.GetRunningServerRequest{}) |
| 175 | if err != nil { |
| 176 | return 0, "", fmt.Errorf("failed to invoke JupyterLab RPC: %w", err) |
| 177 | } |
| 178 | |
| 179 | if !response.Result { |
| 180 | return 0, "", fmt.Errorf("failed to start JupyterLab: %s", response.Message) |
| 181 | } |
| 182 | |
| 183 | port, err = strconv.Atoi(response.Port) |
| 184 | if err != nil { |
| 185 | return 0, "", fmt.Errorf("failed to parse JupyterLab port: %w", err) |
| 186 | } |
| 187 | |
| 188 | if !isJupyterServerURLValid(response.ServerUrl) { |
| 189 | return 0, "", fmt.Errorf("invalid JupyterLab server URL: %q", response.ServerUrl) |
| 190 | } |
| 191 | |
| 192 | return port, response.ServerUrl, nil |
| 193 | } |
| 194 | |
| 195 | // Rebuilds the container using cached layers by default or from scratch if full is true |
| 196 | func (i *invoker) RebuildContainer(ctx context.Context, full bool) error { |
nothing calls this directly
no test coverage detected