Skip to content

Commit 71f56a6

Browse files
author
msxfscyx
committed
3.9.3 pyspark 环境管理
1 parent 440697d commit 71f56a6

File tree

17 files changed

+512
-112
lines changed

17 files changed

+512
-112
lines changed

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"[python]": {
2626
"editor.formatOnSave": true,
2727
"editor.codeActionsOnSave": {
28-
"source.organizeImports": true
28+
"source.organizeImports": "explicit"
2929
}
3030
},
3131
"[typescript]": {
@@ -53,7 +53,7 @@
5353
"prettier.printWidth": 120,
5454
"prettier.singleQuote": true,
5555
"editor.codeActionsOnSave": {
56-
"source.fixAll.eslint": true
56+
"source.fixAll.eslint": "explicit"
5757
},
5858
"python.languageServer": "Default",
5959
"python.linting.pylintEnabled": false,

package-lock.json

Lines changed: 47 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"quickPickSortByLabel",
2323
"testObserver",
2424
"quickPickItemTooltip",
25-
"saveEditor",
2625
"terminalDataWriteEvent"
2726
],
2827
"author": {
@@ -324,6 +323,10 @@
324323
}
325324
],
326325
"commands": [
326+
{
327+
"command": "pyspark.paramRegister.copy",
328+
"title": "Pyspark ParamRegister Copy"
329+
},
327330
{
328331
"title": "%python.command.python.createNewFile.title%",
329332
"shortTitle": "%python.menu.createNewFile.title%",
@@ -1555,6 +1558,7 @@
15551558
"@vscode/extension-telemetry": "^0.8.4",
15561559
"@vscode/jupyter-lsp-middleware": "^0.2.50",
15571560
"arch": "^2.1.0",
1561+
"axios": "^1.7.4",
15581562
"fs-extra": "^10.0.1",
15591563
"glob": "^7.2.0",
15601564
"hash.js": "^1.1.7",

src/client/api/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ export type Environment = EnvironmentPath & {
157157
* Any specific workspace folder this environment is created for.
158158
*/
159159
readonly workspaceFolder: WorkspaceFolder | undefined;
160+
status: number;
161+
readonly detail: string;
162+
level: number;
160163
}
161164
| undefined;
162165
/**

src/client/browser/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export async function deactivate(): Promise<void> {
5858
}
5959
}
6060

61+
export type PySparkParam = {
62+
[key: string]: string
63+
}
64+
6165
async function runPylance(
6266
context: vscode.ExtensionContext,
6367
pylanceExtension: vscode.Extension<PylanceApi>,

src/client/environmentApi.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ async function resolveEnvironment(path: string, discoveryApi: IDiscoveryAPI): Pr
272272
}
273273

274274
export function convertCompleteEnvInfo(env: PythonEnvInfo): ResolvedEnvironment {
275+
// console.log(`convertCompleteEnvInfo1: ${JSON.stringify(env)}`)
275276
const version = { ...env.version, sysVersion: env.version.sysVersion };
276277
let tool = convertKind(env.kind);
277278
if (env.type && !tool) {
@@ -292,11 +293,15 @@ export function convertCompleteEnvInfo(env: PythonEnvInfo): ResolvedEnvironment
292293
name: env.name === '' ? undefined : env.name,
293294
folderUri: Uri.file(env.location),
294295
workspaceFolder: getWorkspaceFolder(env.searchLocation),
296+
status: env.status ?? 0, // 如果status不存在, 则默认为0
297+
detail: env.detail ?? "",
298+
level: env.level ?? 1
295299
}
296300
: undefined,
297301
version: env.executable.filename === 'python' ? undefined : (version as ResolvedEnvironment['version']),
298302
tools: tool ? [tool] : [],
299303
};
304+
// console.log(`convertCompleteEnvInfo2: ${JSON.stringify(resolvedEnv)}`)
300305
return resolvedEnv;
301306
}
302307

src/client/extension.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ initializeFileLogging(logDispose);
2828
//===============================================
2929
// loading starts here
3030

31-
import { ProgressLocation, ProgressOptions, window } from 'vscode';
31+
import { commands, ProgressLocation, ProgressOptions, window } from 'vscode';
3232
import { buildApi } from './api';
3333
import { IApplicationShell, IWorkspaceService } from './common/application/types';
3434
import { IDisposableRegistry, IExperimentService, IExtensionContext } from './common/types';
@@ -46,6 +46,8 @@ import { WorkspaceService } from './common/application/workspace';
4646
import { disposeAll } from './common/utils/resourceLifecycle';
4747
import { ProposedExtensionAPI } from './proposedApiTypes';
4848
import { buildProposedApi } from './proposedApi';
49+
import ContextManager from './pythonEnvironments/base/locators/composite/envsCollectionService';
50+
import { PySparkParam } from './browser/extension';
4951

5052
durations.codeLoadingTime = stopWatch.elapsedTime;
5153

@@ -63,13 +65,34 @@ export async function activate(context: IExtensionContext): Promise<PythonExtens
6365
let ready: Promise<void>;
6466
let serviceContainer: IServiceContainer;
6567
try {
68+
// 设置 context
69+
ContextManager.getInstance().setContext(context);
6670
const workspaceService = new WorkspaceService();
6771
context.subscriptions.push(
6872
workspaceService.onDidGrantWorkspaceTrust(async () => {
6973
await deactivate();
7074
await activate(context);
7175
}),
7276
);
77+
78+
let gatewayUri = "http://10.245.23.158:8080";
79+
const runEnv = process.env.RUN_ENV;
80+
81+
if (runEnv === 'online') {
82+
console.log('当前运行环境: online');
83+
gatewayUri = "http://easdsp-gateway.msxf.lo";
84+
} else {
85+
console.log('当前运行环境: 非 online');
86+
}
87+
context.globalState.update('gateway.addr', gatewayUri);
88+
89+
context.subscriptions.push(
90+
commands.registerCommand('pyspark.paramRegister.copy', (pySparkParam: PySparkParam) => {
91+
console.log(`PySparkParam-python: ${JSON.stringify(pySparkParam)}`);
92+
context.globalState.update('pyspark.paramRegister.copy', pySparkParam);
93+
}),
94+
);
95+
7396
[api, ready, serviceContainer] = await activateUnsafe(context, stopWatch, durations);
7497
} catch (ex) {
7598
// We want to completely handle the error

src/client/pythonEnvironments/base/info/env.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export function buildEnvInfo(init?: {
4242
sysPrefix?: string;
4343
searchLocation?: Uri;
4444
type?: PythonEnvType;
45+
status?: number;
46+
level?: number;
4547
}): PythonEnvInfo {
4648
const env: PythonEnvInfo = {
4749
name: init?.name ?? '',
@@ -92,7 +94,8 @@ export function areEnvsDeepEqual(env1: PythonEnvInfo, env2: PythonEnvInfo): bool
9294
return (
9395
isEqual(env1Clone, env2Clone) &&
9496
arePathsSame(searchLocation1, searchLocation2) &&
95-
searchLocation1Scheme === searchLocation2Scheme
97+
searchLocation1Scheme === searchLocation2Scheme &&
98+
env1.status === env2.status
9699
);
97100
}
98101

src/client/pythonEnvironments/base/info/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ export type PythonEnvInfo = _PythonEnvInfo & {
201201
display?: string;
202202
detailedDisplayName?: string;
203203
searchLocation?: Uri;
204+
status?: number; // 0: 项目空间同步过来,但未下载 1:本地创建/修改了,但未提交至项目空间 2:本地存在,且项目空间也在
205+
detail?: string; // python env yml
206+
level?: number; // 项目级别 0:公共, 1:项目
204207
};
205208

206209
/**

src/client/pythonEnvironments/base/locator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ export type BasicEnvInfo = {
144144
executablePath: string;
145145
source?: PythonEnvSource[];
146146
envPath?: string;
147+
status?: number; // 如果status不存在, 则默认为0
148+
detail?: string;
149+
level?: number;
147150
};
148151

149152
/**

0 commit comments

Comments
 (0)