This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env cwl-runner | |
| cwlVersion: v1.0 | |
| class: Workflow | |
| label: Create detector from folder | |
| doc: Given a folder and a name, creates a detector with this name and trainable on the rasters in the folder | |
| inputs: | |
| api_key: string | |
| api_server: string | |
| raster_folder_id: string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs') | |
| const path = require('path') | |
| const fetch = require('node-fetch') | |
| const Headers = fetch.Headers | |
| const sleep = ms => new Promise(resolve=> setTimeout(resolve,ms)) | |
| const apiKey = "123456789" | |
| const apiServer = 'https://app.picterra.ch/public/api/v1' | |
| if (process.argv.length <= 3) { | |
| console.log("Usage: " + __filename + " path/to/directory detector_name"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def detect(detector_id, raster_id): | |
| server_url = "https://picterra.ch/public/api/v1" # Picterra Public API server | |
| headers = { 'X-Api-Key': "123456789" } # Get API key on the Picterra platform | |
| url = server_url + ("/detectors/%s/run/" % detector_id) | |
| requests.post(url, headers=headers, data={'raster_id': raster_id}) | |
| response = r.json() # Start prediction | |
| result_id = response["result_id"] | |
| poll_interval = response["poll_interval"] # Waiting interval | |
| url = server_url + ("/results/%s/" % result_id) | |
| while True: # Wait until prediction is finished |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def upload_and_commit(file_path, file_name): | |
| api_key = "123456789" # Get it on the platform | |
| server_url = "https://app.picterra.ch/public/api/v1" | |
| headers = { 'X-Api-Key': api_key } | |
| url = server_url + "/rasters/upload/file/" # Endpoint to get remote upload URL | |
| r = requests.post(url, headers=headers, data={'name': file_name}) | |
| response = r.json() | |
| upload_url = response["upload_url"] # Save upload URL | |
| raster_id = response["raster_id"] # Save raster identifier | |
| size = os.stat(file_path).st_size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function detect(raster, detectorId, directory) { | |
| const rasterId = raster.id | |
| const rasterName = raster.name | |
| const sleep = s => new Promise(resolve=> setTimeout(resolve, s * 1000)) | |
| const apiKey = "123456789" | |
| const apiServer = "https://app.picterra.ch/public/api/v1" | |
| let options = { | |
| method: 'POST', | |
| headers: new Headers({ | |
| 'Content-Type': 'application/json', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function upload(filePath, fileName) { | |
| const sleep = s => new Promise(resolve=> setTimeout(resolve, s * 1000)) | |
| const apiKey = "123456789" | |
| const apiServer = "https://app.picterra.ch/public/api/v1" | |
| let options = { | |
| method: 'POST', | |
| headers: new Headers({ | |
| 'Content-Type': 'application/json', | |
| 'X-Api-Key': apiKey}), | |
| body: JSON.stringify({'name': fileName})} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs') | |
| const path = require('path') | |
| const fetch = require('node-fetch') | |
| const Headers = fetch.Headers | |
| const sleep = ms => new Promise(resolve=> setTimeout(resolve,ms)) | |
| const apiKey = "" | |
| const apiServer = 'https://app-testing.picterra.ch/public/api/v1' | |
| if (process.argv.length <= 2) { | |
| console.log("Usage: " + __filename + " path/to/directory"); |