Socket
Socket
Sign inDemoInstall

roboflow

Package Overview
Dependencies
243
Maintainers
8
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.9 to 0.0.10

cli/commands/project.js

54

api.js

@@ -52,13 +52,46 @@ const config = require("./config.js");

const response = await axios({
method: "POST",
url: `${config.get("RF_API_URL")}/dataset/` + projectUrl + "/upload",
params: {
api_key: apiKey
},
data: formData,
headers: formData.getHeaders()
});
try {
const response = await axios({
method: "POST",
url: `${config.get("RF_API_URL")}/dataset/` + projectUrl + "/upload",
params: {
api_key: apiKey
},
data: formData,
headers: formData.getHeaders()
});
return response.data;
} catch (e) {
if (e.response) {
return e.response.data;
}
throw e;
}
}
return response.data;
async function uploadAnnotation(imageID, annotationFile, projectUrl, apiKey) {
const filename = path.basename(annotationFile);
const annotationData = fs.readFileSync(annotationFile, "utf-8");
try {
const response = await axios({
method: "POST",
url: `${config.get("RF_API_URL")}/dataset/${projectUrl}/annotate/${imageID}`,
params: {
api_key: apiKey,
name: filename
},
data: annotationData,
headers: {
"Content-Type": "text/plain"
}
});
return response.data;
} catch (e) {
if (e.response) {
return e.response.data;
}
throw e;
}
}

@@ -153,2 +186,3 @@

uploadImage,
uploadAnnotation,
detectObject,

@@ -155,0 +189,0 @@ classify,

@@ -5,5 +5,5 @@ const fs = require("fs");

const { selectProjectFromWorkspace, getApiKeyWorWorkspace } = require("../core.js");
const { uploadImage } = require("../../api.js");
const api = require("../../api.js");
module.exports = async function upload(args, options) {
async function uploadImage(args, options) {
const workspaceUrl = options.workspace;

@@ -34,6 +34,44 @@ const apiKey = getApiKeyWorWorkspace(workspaceUrl);

for (var f of args) {
const result = await uploadImage(f, projectUrl, apiKey, extraOptions);
console.log(result);
if (options.annotation) {
for (var f of args) {
// console.log("upload:", f, projectUrl, apiKey, extraOptions);
const uploadResult = await api.uploadImage(f, projectUrl, apiKey, extraOptions);
console.log("image uploaded: ", uploadResult);
const imageId = uploadResult.id;
let annotationFilename = options.annotation;
if (annotationFilename.includes("[filename]")) {
annotationFilename = annotationFilename.replace("[filename]", path.parse(f).name);
}
if (fs.existsSync(annotationFilename)) {
const annotationResult = await api.uploadAnnotation(
imageId,
annotationFilename,
projectUrl,
apiKey
);
console.log("annotation uploaded:", annotationResult);
} else {
console.log(
`cant stat annotation file: '${annotationFilename}'. image uplaoded without annotation`
);
continue;
}
}
} else {
// console.log("upload unanotated", args, options);
for (var f of args) {
console.log("upload:", f, projectUrl, apiKey, extraOptions);
// const result = await api.uploadImage(f, projectUrl, apiKey, extraOptions);
console.log("image uplaoded:", result);
}
}
}
module.exports = {
uploadImage
};

@@ -9,4 +9,4 @@ #! /usr/bin/env node

const selectDefaultWorkspace = require("./commands/selectDefaultWorkspace.js");
const listWorkspaces = require("./commands/listWorkspaces.js");
const listProjects = require("./commands/listProjects.js");
const workspaceCommands = require("./commands/workspace.js");
const projectCommands = require("./commands/project.js");
const upload = require("./commands/upload.js");

@@ -28,3 +28,6 @@ const open = require("./commands/open.js");

program.addHelpText("before", `\nroboflow cli: computer vision at your fingertips 🪄\n`);
program.addHelpText(
"before",
`\nWelcome to the roboflow CLI: computer vision at your fingertips 🪄\n`
);

@@ -43,3 +46,3 @@ program.option("-d, --debug", "print verbose debugging info").on("option:debug", function () {

.command("open")
.description("opens a roboflow workspace or project in your browser")
.description("opens a roboflow workspace in your browser")
.option(

@@ -133,3 +136,9 @@ "-w --workspace [workspace]",

)
.argument("<files...>")
.option("-b --batch <batch>", "specify a batch to add the uploaded image to")
.option(
"-a --annotation <annotationFile>",
"specify an annotation filename. you can pass e.g. '[filename].xml to match based on the image filename'"
)
.addOption(

@@ -141,6 +150,4 @@ new Option(

)
.action(upload.uploadImage);
.argument("<files...>")
.action(upload);
// workspace subcommands

@@ -155,4 +162,17 @@ const workspace = new Command("workspace").description(

workspace.command("list").description("list workspaces").action(listWorkspaces);
workspace
.command("get")
.description("show detailed info for a workspace")
.option(
"-w --workspace [workspace]",
"specify a workspace url or id (will use default workspace if not specified)",
defaultWorkspace
)
.action(workspaceCommands.workspaceDetails);
workspace
.command("list")
.description("list workspaces")
.action(workspaceCommands.listWorkspaces);
program.addCommand(workspace);

@@ -173,4 +193,15 @@

)
.action(listProjects);
.action(projectCommands.listProjects);
project
.command("get")
.description("show detailed info for a project")
.option(
"-w --workspace [workspace]",
"specify a workspace url or id (will use default workspace if not specified)",
defaultWorkspace
)
.argument("<projectId>")
.action(projectCommands.projectDetails);
program.addCommand(project);

@@ -187,4 +218,7 @@

} catch (e) {
// console.error(e);
console.log("Exiting due to error: ", e.message);
console.error(e.message);
if (global.debug) {
console.log("[debug]", e);
}
process.exit(1);

@@ -191,0 +225,0 @@ }

5

package.json
{
"name": "roboflow",
"version": "0.0.9",
"version": "0.0.10",
"description": "Roboflow.ai node module and CLI tools",

@@ -25,3 +25,4 @@ "main": "index.js",

"npm": "^8.19.2",
"open": "^8.4.0"
"open": "^8.4.0",
"terminal-link": "^2.1.1"
},

@@ -28,0 +29,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc