Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Components] v7_darwin #12908 #13628

Merged
merged 8 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions components/v7_darwin/actions/add-instructions/add-instructions.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import app from "../../v7_darwin.app.mjs";

export default {
key: "v7_darwin-add-instructions",
name: "Add Instructions",
description: "Add annotator instructions. [See the documentation](https://docs.v7labs.com/reference/adding-instructions)",
version: "0.0.1",
type: "action",
props: {
app,
id: {
propDefinition: [
app,
"id",
],
},
instructions: {
propDefinition: [
app,
"instructions",
],
description: "String of instructions. Written using HTML",
},
},
async run({ $ }) {
const response = await this.app.addInstructions({
$,
dataset_id: this.id,
data: {
instructions: this.instructions,
},
});

$.export("$summary", `Successfully created Instruction in dataset with ID: '${this.id}'`);

return response;
},
};
30 changes: 30 additions & 0 deletions components/v7_darwin/actions/create-dataset/create-dataset.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import app from "../../v7_darwin.app.mjs";

export default {
key: "v7_darwin-create-dataset",
name: "Create Dataset",
description: "Creates a new Dataset. [See the documentation](https://docs.v7labs.com/reference/create-dataset)",
version: "0.0.1",
type: "action",
props: {
app,
name: {
propDefinition: [
app,
"name",
],
},
},
async run({ $ }) {
const response = await this.app.createDataset({
$,
data: {
name: this.name,
},
});

$.export("$summary", `Successfully created Dataset with ID: '${response.id}'`);

return response;
},
};
86 changes: 86 additions & 0 deletions components/v7_darwin/actions/update-dataset/update-dataset.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import app from "../../v7_darwin.app.mjs";

export default {
key: "v7_darwin-update-dataset",
name: "Update Dataset",
description: "Update a dataset with the specified ID. [See the documentation](https://docs.v7labs.com/reference/update-dataset)",
version: "0.0.1",
type: "action",
props: {
app,
id: {
propDefinition: [
app,
"id",
],
},
annotatorsCanCreateTags: {
propDefinition: [
app,
"annotatorsCanCreateTags",
],
},
annotatorsCanInstantiateWorkflows: {
propDefinition: [
app,
"annotatorsCanInstantiateWorkflows",
],
},
anyoneCanDoubleAssign: {
propDefinition: [
app,
"anyoneCanDoubleAssign",
],
},
instructions: {
propDefinition: [
app,
"instructions",
],
},
name: {
propDefinition: [
app,
"name",
],
},
public: {
propDefinition: [
app,
"public",
],
},
reviewersCanAnnotate: {
propDefinition: [
app,
"reviewersCanAnnotate",
],
},
workPrioritization: {
propDefinition: [
app,
"workPrioritization",
],
},
},
async run({ $ }) {
const response = await this.app.updateDataset({
$,
id: this.id,
data: {
annotators_can_create_tags: this.annotatorsCanCreateTags,
annotators_can_instantiate_workflows: this.annotatorsCanInstantiateWorkflows,
anyone_can_double_assign: this.anyoneCanDoubleAssign,
instructions: this.instructions,
name: this.name,
public: this.public,
reviewers_can_annotate: this.reviewersCanAnnotate,
work_prioritization: this.workPrioritization,
},
});

$.export("$summary", `Successfully updated Dataset with ID: '${this.id}'`);

return response;
},
};
8 changes: 8 additions & 0 deletions components/v7_darwin/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
PRIORITY_OPTIONS: [
"priority:asc",
"priority:desc",
"inserted_at:asc",
"inserted_at:asc",
],
};
7 changes: 5 additions & 2 deletions components/v7_darwin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/v7_darwin",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream V7 Darwin Components",
"main": "v7_darwin.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
}
}
}
114 changes: 110 additions & 4 deletions components/v7_darwin/v7_darwin.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,117 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "v7_darwin",
propDefinitions: {},
propDefinitions: {
id: {
type: "string",
label: "Dataset ID",
description: "ID of the Dataset",
async options() {
const endusersIds = await this.listDatasets();
return endusersIds.map(({
id, name,
}) => ({
value: id,
label: name,
}));
},
},
name: {
type: "string",
label: "Name",
description: "The name of the new dataset",
},
annotatorsCanCreateTags: {
type: "boolean",
label: "Annotators Can Create Tags",
description: "Flag to specify whether annotators are allowed to create tags for the specified dataset",
},
annotatorsCanInstantiateWorkflows: {
type: "boolean",
label: "Annotators Can Instantiate Workflows",
description: "Flag to specify whether annotators can get assigned items in 'new' status",
},
anyoneCanDoubleAssign: {
type: "boolean",
label: "Anyone Can Double Assign",
description: "Flag to specify whether users can be assigned to different stages in the same workflow",
},
instructions: {
type: "string",
label: "Instructions",
description: "Dataset instructions for annotators",
},
public: {
type: "boolean",
label: "Public",
description: "Flag to specify whether the dataset should be publicly accessible",
},
reviewersCanAnnotate: {
type: "boolean",
label: "Reviewers Can Annotate",
description: "Flag to specify whether reviewers are allowed to create annotations in review stages",
},
workPrioritization: {
type: "string",
label: "Work Prioritization",
description: "Specification for sorting items when annotators request new items",
options: constants.PRIORITY_OPTIONS,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://darwin.v7labs.com/api";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"Authorization": `ApiKey ${this.$auth.api_key}`,
"Content-Type": "application/json",
},
});
},
async createDataset(args = {}) {
return this._makeRequest({
method: "post",
path: "/datasets",
...args,
});
},
async updateDataset({
id, ...args
}) {
return this._makeRequest({
method: "put",
path: `/datasets/${id}`,
...args,
});
},
async addInstructions({
dataset_id, ...args
}) {
return this._makeRequest({
method: "put",
path: `/datasets/${dataset_id}`,
...args,
});
},
async listDatasets(args = {}) {
return this._makeRequest({
path: "/datasets",
...args,
});
},
},
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading