Files in a project

Use the project's file area to hold data, scripts and models. The file routes are under /api/v1/projects/<project_id>/ and check that you are signed in.

RouteWhat it does
GET filesList a folder. The path parameter selects it. Paths containing .. are rejected. Dot files and __pycache__ are hidden. Each entry has a type: python, data, model, image, config, text, file or directory.
POST filesCreate a file. Body fields path and content.
POST uploadMultipart form. The file field holds the file. The destination form field defaults to data. File names are made safe, and a duplicate name gets _1 added. Returns 201 with the path and size.
GET, PUT, DELETE files/<path>Read, replace or delete a file.
GET files/download/<path>Download a file.
GET files/profile/<path>Data profile of a data file.
GET data-columns?file_path=...Column names of a data file.
GET data-preview?file_path=...&rows=10First rows of a data file.

The tabular routes return 503 with the text Tabular data support is unavailable in the current Python environment when pandas cannot be loaded.

curl -X POST http://127.0.0.1:5001/api/v1/projects/12/upload \
  -H "X-API-Key: <your-key>" \
  -F "file=@train.csv" -F "destination=data"

Kaggle datasets

MLStudio can search Kaggle, download a dataset into a project, or create a new project around a dataset. These routes are under /api/datasets (not /api/v1). Their errors come back as {"error": "..."} without a success field. Every route needs you to be signed in.

Set up Kaggle access

  1. An administrator stores the Kaggle user name and key on the dataset marketplace admin page (/admin/settings/dataset-marketplace/), or sets the environment variables KAGGLE_USERNAME and KAGGLE_API_KEY. Database values are used first.
  2. Optionally, each user can store their own Kaggle credentials with POST /api/datasets/config/kaggle (body api_username and api_key). They are stored encrypted. GET on the same route returns configured, has_admin_default and username.

Search itself uses the administrator credentials. Without them, search answers 503 with Kaggle not configured.

Routes

RouteWhat it does
GET /api/datasets/searchParameters query, source (kaggle), sort (for example hottest), limit (default 20, maximum 50). An empty query returns an empty list. Each result has id, name, title, description, owner, downloads, votes, usability, size_kb, license, source and source_url.
GET /api/datasets/trendingParameter limit, default 6, maximum 20.
GET /api/datasets/<source>/<dataset_id>Details of one dataset.
POST /api/datasets/downloadBody source, dataset_id, dataset_name. Returns 201 with message and download_id.
GET /api/datasets/downloads/<id>/statusFields include id, status, progress, file_path, size_bytes and error_message.
POST /api/datasets/downloads/<id>/cancelCancel a download.
POST /api/datasets/downloads/<id>/retryRetry a download.
POST /api/datasets/create-project-with-datasetCreates a project and downloads a dataset in one step. See below.

Create a project with a dataset

Body fields: name (3 to 100 characters), dataset_id (required), dataset_source (kaggle), dataset_name, template, framework, environment_option (new, existing or other), environment_name, description. A second request within 5 seconds of your last project creation returns 429. A success returns 201 with project_id, download_id, project_name and dataset_name. Download progress is also pushed to the browser over Socket.IO.

curl -X POST http://127.0.0.1:5001/api/datasets/create-project-with-dataset \
  -H "X-API-Key: <your-key>" -H "Content-Type: application/json" \
  -d '{"name": "titanic-study", "dataset_id": "owner/dataset-slug", "dataset_source": "kaggle", "dataset_name": "Titanic", "framework": "scikit-learn", "environment_option": "new"}'