trainfabric 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +46 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8817,13 +8817,22 @@ var import_node_fs = __toESM(require("node:fs"), 1);
|
|
|
8817
8817
|
var import_node_os = __toESM(require("node:os"), 1);
|
|
8818
8818
|
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
8819
8819
|
function collectRuntimeFiles(repoPath) {
|
|
8820
|
-
const manifestFiles = /* @__PURE__ */ new Set([
|
|
8820
|
+
const manifestFiles = /* @__PURE__ */ new Set([
|
|
8821
|
+
"training.yaml",
|
|
8822
|
+
"train.runtime.yaml",
|
|
8823
|
+
"pyproject.toml",
|
|
8824
|
+
"requirements.txt",
|
|
8825
|
+
"environment.yml",
|
|
8826
|
+
"Dockerfile"
|
|
8827
|
+
]);
|
|
8828
|
+
const configExtensions = /* @__PURE__ */ new Set([".yaml", ".yml", ".json", ".toml"]);
|
|
8821
8829
|
const ignoredDirectories = /* @__PURE__ */ new Set([".git", ".hg", ".svn", "node_modules", ".venv", "venv", "__pycache__", ".mypy_cache", ".pytest_cache", "dist", "build"]);
|
|
8822
8830
|
const found = [];
|
|
8823
8831
|
const maxFiles = 256;
|
|
8824
8832
|
const maxFileBytes = 256 * 1024;
|
|
8825
8833
|
function shouldIncludeFile(fileName) {
|
|
8826
|
-
|
|
8834
|
+
const extension = import_node_path2.default.extname(fileName).toLowerCase();
|
|
8835
|
+
return manifestFiles.has(fileName) || configExtensions.has(extension) || fileName.endsWith(".py");
|
|
8827
8836
|
}
|
|
8828
8837
|
function walk(currentPath) {
|
|
8829
8838
|
if (found.length >= maxFiles) {
|
|
@@ -8945,7 +8954,7 @@ function buildComputeSpec(options) {
|
|
|
8945
8954
|
|
|
8946
8955
|
// src/index.ts
|
|
8947
8956
|
var DEFAULT_TRAINFABRIC_API_URL2 = "https://api.trainfabric.com";
|
|
8948
|
-
var CLI_VERSION = "0.1.
|
|
8957
|
+
var CLI_VERSION = "0.1.23";
|
|
8949
8958
|
var CONFIG_DIR = import_node_path3.default.join(import_node_os2.default.homedir(), ".trainfabric");
|
|
8950
8959
|
var CONFIG_PATH = import_node_path3.default.join(CONFIG_DIR, "config.json");
|
|
8951
8960
|
var FALLBACK_SECRET_PATH = import_node_path3.default.join(CONFIG_DIR, "session.enc");
|
|
@@ -9409,6 +9418,21 @@ function createClient(config) {
|
|
|
9409
9418
|
projectId: config.projectId
|
|
9410
9419
|
});
|
|
9411
9420
|
}
|
|
9421
|
+
function normalizeHttpBaseUrl(value) {
|
|
9422
|
+
let url;
|
|
9423
|
+
try {
|
|
9424
|
+
url = new URL(value);
|
|
9425
|
+
} catch {
|
|
9426
|
+
throw new Error(`Invalid base URL "${value}". Use an absolute http(s) URL such as https://api.trainfabric.com.`);
|
|
9427
|
+
}
|
|
9428
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
9429
|
+
throw new Error(`Invalid base URL "${value}". Use an absolute http(s) URL such as https://api.trainfabric.com.`);
|
|
9430
|
+
}
|
|
9431
|
+
url.pathname = url.pathname.replace(/\/+$/, "");
|
|
9432
|
+
url.search = "";
|
|
9433
|
+
url.hash = "";
|
|
9434
|
+
return url.toString().replace(/\/+$/, "");
|
|
9435
|
+
}
|
|
9412
9436
|
async function login(config) {
|
|
9413
9437
|
const apiKey = await promptApiKey();
|
|
9414
9438
|
if (!apiKey) {
|
|
@@ -9454,20 +9478,32 @@ program2.command("config:show").description("Show the active CLI configuration")
|
|
|
9454
9478
|
printJson(visibleConfig(loadConfig()));
|
|
9455
9479
|
});
|
|
9456
9480
|
program2.command("config:set-base-url").argument("<baseUrl>").description("Set the backend base URL").action((baseUrl) => {
|
|
9481
|
+
const normalizedBaseUrl = normalizeHttpBaseUrl(String(baseUrl));
|
|
9457
9482
|
const config = updateConfig((current) => {
|
|
9458
|
-
current.baseUrl =
|
|
9483
|
+
current.baseUrl = normalizedBaseUrl;
|
|
9459
9484
|
});
|
|
9460
9485
|
printJson(visibleConfig(config));
|
|
9461
9486
|
});
|
|
9462
|
-
program2.command("config:set-org").argument("<orgId>").description("Set the default organization ID").action((orgId) => {
|
|
9463
|
-
const
|
|
9464
|
-
|
|
9487
|
+
program2.command("config:set-org").argument("<orgId>").description("Set the default organization ID").action(async (orgId) => {
|
|
9488
|
+
const currentConfig = loadConfig();
|
|
9489
|
+
const organization = await createClient(currentConfig).organizations.get(String(orgId));
|
|
9490
|
+
const updatedConfig = updateConfig((current) => {
|
|
9491
|
+
current.orgId = organization.id;
|
|
9492
|
+
if (current.projectId) {
|
|
9493
|
+
current.projectId = void 0;
|
|
9494
|
+
}
|
|
9465
9495
|
});
|
|
9466
|
-
printJson(visibleConfig(
|
|
9496
|
+
printJson(visibleConfig(updatedConfig));
|
|
9467
9497
|
});
|
|
9468
|
-
program2.command("config:set-project").argument("<projectId>").description("Set the default project ID").action((projectId) => {
|
|
9498
|
+
program2.command("config:set-project").argument("<projectId>").description("Set the default project ID").action(async (projectId) => {
|
|
9499
|
+
const currentConfig = loadConfig();
|
|
9500
|
+
const project = await createClient(currentConfig).projects.get(String(projectId));
|
|
9501
|
+
if (currentConfig.orgId && project.organizationId !== currentConfig.orgId) {
|
|
9502
|
+
throw new Error(`Project ${project.id} does not belong to configured organization ${currentConfig.orgId}.`);
|
|
9503
|
+
}
|
|
9469
9504
|
const config = updateConfig((current) => {
|
|
9470
|
-
current.projectId =
|
|
9505
|
+
current.projectId = project.id;
|
|
9506
|
+
current.orgId ??= project.organizationId;
|
|
9471
9507
|
});
|
|
9472
9508
|
printJson(visibleConfig(config));
|
|
9473
9509
|
});
|