# Export Projects

### How It Works

```bash
$ npm run start -- export-projects -h
Usage: robosaur export-projects [options] <configFile>

Export all projects based on the given config file

Options:
  -u --unzip  Unzips the exported projects, only storing the final version accepted by reviewers
  -h, --help  display help for command
```

* Robosaur will try to export each projects previously created by the `create-projects` command. Each project will be saved as a separate zip file under the supplied directory in `export.prefix`.
* By default, Robosaur will request for a full project export - with each labelers' version of the project document included. For simpler workflows, where we only need the final version of the document, we can use the `--unzip` option. With this option set, Robosaur will only save the final version of the document to the export destination.
* Robosaur will export all the projects that fulfilled the filter and not yet recorded by the state. It will only export each project once.

### Configuration

```json
{
  ...
  "export": {
    "source": "local",
    "prefix": "path/to/export/root",
    "teamId": "<TEAM_ID>",
    "statusFilter": [],
    "format": "JSON_ADVANCED",
    "fileTransformerId": null
  },
  ...
}
```

#### Storage Options

Just like any other source, you can find the detailed explanation [here](https://datasaurai.gitbook.io/datasaur/integrations/robosaur/commands/export-projects).

#### Format

Refers to the export result. Please see this [page](https://datasaurai.gitbook.io/datasaur/compatibility-and-updates/supported-formats) to know all the supported formats.

#### File Transformer ID

If you want to custom transformation for your export result, you can utilize this custom script.

1. You must create it on the app through <https://app.datasaur.ai/teams/{team-ID}/custom-scripts>.
2. Open the custom script and get the ID from the URL.

#### Filter <a href="#execution-modes" id="execution-modes"></a>

Robosaur supports filtering which project to export by the project status. Overall, there are five different project statuses, from earliest to the latest. If it's empty, then it won't filter any statuses.

* `CREATED`: projects that haven't been opened by any labelers
* `IN_PROGRESS`: project that have been opened by one of the labelers
* `REVIEW_READY`: projects that have been finished by all of the labelers
* `IN_REVIEW`: projects in `REVIEW_READY` that have been opened by one of the reviewers
* `COMPLETE`: projects that are already marked as completed by any reviewers

### Execution Modes <a href="#execution-modes" id="execution-modes"></a>

#### **Stateful Project Export (Default Approach)** <a href="#stateful-project-creation--export" id="stateful-project-creation--export"></a>

In project export using `export-projects`, the JSON state file that is configured by `projectState` attribute is treated as the source of truth.

**Only projects found in the state file, i.e. projects that are created by Robosaur, will be checked against the `statusFilter` and exported**. Robosaur will also record the project state when it was last exported, and subsequent runs will only export the project if there had been a forward change in the project status.

#### Stateless project export <a href="#stateless-project-export" id="stateless-project-export"></a>

Robosaur also supports exporting projects that are not created by Robosaur (stateless). To do this add the following options to the configuration file:

1. `"executionMode"`

   Specifies whether the projects to be exported is created with Robosaur or not. Fill with `"stateless"` for projects created outside Robosaur and `"stateful"` for projects created with Robosaur. The default value is `"stateful"`.
2. `"projectFilter"`

   Specifies which projects to be exported. Contains the following value:

   * `"kind"` (required)

     `TOKEN_BASED`, `ROW_BASED`, or `DOCUMENT_BASED`
   * `"date"`
     * `"newestDate"` (required)

       Ignores all projects created after this date.
     * `"oldestDate"`

       Ignores all projects created before this date.

See the example configuration below.

```json
...
"export": {
  "source": "local",
  "prefix": "quickstart/token-based/export",
  "teamId": "1",
  "statusFilter": [],
  "executionMode": "stateless",
  "projectFilter": {
    "kind": "TOKEN_BASED",
    "date": {
      "newestDate": "2022-03-11",
      "oldestDate": "2022-03-07"
    }
  },
  "format": "JSON_ADVANCED",
  "fileTransformerId": null
},
...
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datasaur.ai/integrations/robosaur/commands/export-projects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
