本文整理汇总了TypeScript中rx-jupyter.kernels类的典型用法代码示例。如果您正苦于以下问题:TypeScript kernels类的具体用法?TypeScript kernels怎么用?TypeScript kernels使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了kernels类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: mergeMap
mergeMap(({ payload: { serverId, kernelName } }) => {
const configPath = [
"entities",
"serversById",
serverId,
"server",
"config"
];
const config = objectPath.get(state$.value, configPath);
return kernels.start(config, kernelName, "").pipe(
mergeMap(data => {
const session = uuid();
const kernel = Object.assign({}, data.response, {
channel: kernels.connect(
config,
data.response.id,
session
)
});
kernel.channel.next(kernelInfoRequest());
return merge(
of(
actions.activateKernelFulfilled({
serverId,
kernelName,
kernel
})
)
);
})
);
})
开发者ID:nteract,项目名称:play,代码行数:34,代码来源:epics.ts
示例2: mergeMap
mergeMap(data => {
const session = data.response;
const sessionId = castToSessionId(session.id);
const kernel: RemoteKernelProps = Object.assign({}, session.kernel, {
type: "websocket",
info: null,
sessionId,
cwd,
channels: kernels.connect(
serverConfig,
session.kernel.id,
sessionId
),
kernelSpecName
});
kernel.channels.next(kernelInfoRequest());
return of(
actions.launchKernelSuccessful({
kernel,
kernelRef,
contentRef: action.payload.contentRef,
selectNextKernel: true
})
);
}),
开发者ID:nteract,项目名称:nteract,代码行数:29,代码来源:websocket-kernel.ts
示例3: concatMap
concatMap((action: actions.InterruptKernel) => {
const state = state$.value;
const host = selectors.currentHost(state);
if (host.type !== "jupyter") {
// Dismiss any usage that isn't targeting a jupyter server
return empty();
}
const serverConfig: ServerConfig = selectors.serverConfig(host);
const kernel = selectors.currentKernel(state);
if (!kernel) {
return of(
actions.interruptKernelFailed({
error: new Error("Can't interrupt a kernel we don't have"),
kernelRef: action.payload.kernelRef
})
);
}
if (kernel.type !== "websocket" || !kernel.id) {
return of(
actions.interruptKernelFailed({
error: new Error("Invalid kernel type for interrupting"),
kernelRef: action.payload.kernelRef
})
);
}
const id = kernel.id;
return kernels.interrupt(serverConfig, id).pipe(
map(() =>
actions.interruptKernelSuccessful({
kernelRef: action.payload.kernelRef
})
),
catchError(err =>
of(
actions.interruptKernelFailed({
error: err,
kernelRef: action.payload.kernelRef
})
)
)
);
})
开发者ID:nteract,项目名称:nteract,代码行数:47,代码来源:websocket-kernel.ts
示例4: checkUp
async checkUp(host: HostRecord): Promise<boolean> {
if (host.type !== UP) {
return false;
}
return kernels
.list(host.config)
.pipe(
map(xhr => {
console.log(xhr);
return true;
}),
catchError(err => {
console.error("error listing kernels on server", err);
return of(false);
})
)
.toPromise();
}
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:19,代码来源:host-storage.ts
示例5: switchMap
switchMap((action: actions.ChangeKernelByName) => {
const {
payload: { contentRef, oldKernelRef, kernelSpecName }
} = action;
const state = state$.value;
const host = selectors.currentHost(state);
if (host.type !== "jupyter") {
// Dismiss any usage that isn't targeting a jupyter server
return empty();
}
const serverConfig: ServerConfig = selectors.serverConfig(host);
// TODO: This is the case where we didn't have a kernel before
// and they chose to switch kernels. Instead we need to allow
// "switching" by disregarding the previous kernel and creating a
// new session
if (!oldKernelRef) {
return empty();
}
const oldKernel = selectors.kernel(state, { kernelRef: oldKernelRef });
if (!oldKernel || oldKernel.type !== "websocket") {
return empty();
}
const { sessionId } = oldKernel;
if (!sessionId) {
return empty();
}
const content = selectors.content(state, { contentRef });
if (!content || content.type !== "notebook") {
return empty();
}
const {
filepath,
model: { notebook }
} = content;
const { cwd } = extractNewKernel(filepath, notebook);
const kernelRef = createKernelRef();
return kernels.start(serverConfig, kernelSpecName, cwd).pipe(
mergeMap(({ response }) => {
const { id: kernelId } = response;
const sessionPayload = {
kernel: { id: kernelId, name: kernelSpecName }
};
// The sessions API will close down the old kernel for us if it is
// on this session
return sessions.update(serverConfig, sessionId, sessionPayload).pipe(
mergeMap(({ response: session }) => {
const kernel: RemoteKernelProps = Object.assign(
{},
session.kernel,
{
type: "websocket",
sessionId,
cwd,
channels: kernels.connect(
serverConfig,
session.kernel.id,
sessionId
),
kernelSpecName
}
);
return of(
actions.launchKernelSuccessful({
kernel,
kernelRef,
contentRef: action.payload.contentRef,
selectNextKernel: true
})
);
}),
catchError(error =>
of(actions.launchKernelFailed({ error, kernelRef, contentRef }))
)
);
}),
catchError(error =>
of(actions.launchKernelFailed({ error, kernelRef, contentRef }))
)
);
})
开发者ID:nteract,项目名称:nteract,代码行数:84,代码来源:websocket-kernel.ts
注:本文中的rx-jupyter.kernels类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论