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

Refactor export_annotations command. Update changelog. Add util command documentation. #392

Closed
wants to merge 2 commits into from
Closed
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
24 changes: 21 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

### Fixed


## [2.1.1] 2023-10-02

### Important Notice!
In versions from 0.2.0 to 2.1.0 inclusive the default `docker-compose.yml` file fails to back up the database, due to a mismatch between the version of the database server and the version of the backup client. This is now fixed, but in order to create a proper database backup before attempting to upgrade you will need to manually edit your `docker-compose.yml` file and change

```yaml
Expand All @@ -27,10 +31,24 @@ docker compose run --rm -it pgbackups /backup.sh

(or `docker-compose` if your version of Docker does not support compose v2).

## [2.1.1] 2023-10-02

### Added
- Script for extracting annotations without web UI
- Script for extracting annotations without web UI ([#386](https://github.com/GateNLP/gate-teamware/pull/386))
- Support upgrades as well as fresh installs for get-teamware.sh script ([#383](https://github.com/GateNLP/gate-teamware/pull/383))
- Add transition effect when document changes ([#367](https://github.com/GateNLP/gate-teamware/pull/367))
- Implement conditional widgets ([#350](https://github.com/GateNLP/gate-teamware/pull/350))

### Changed
- Attempt to spread documents more evenly across annotators ([#384](https://github.com/GateNLP/gate-teamware/pull/384))
- Upgrade postgres-backup-local to version 14 ([#382](https://github.com/GateNLP/gate-teamware/pull/382))
- enable version.py update to take version number as argument ([#365](https://github.com/GateNLP/gate-teamware/pull/365))

### Fixed
- Correct error in navbar property setting ([#376](https://github.com/GateNLP/gate-teamware/pull/376))
- User-level DB lock in get_annotator_task to avoid race condition #375 ([#376](https://github.com/GateNLP/gate-teamware/pull/376))
- Better frontend error page when backend is down ([#368](https://github.com/GateNLP/gate-teamware/pull/368))
- Correct DOI ([#364](https://github.com/GateNLP/gate-teamware/pull/364))
- Clear pending annotations when rejecting a user from a project ([#362](https://github.com/GateNLP/gate-teamware/pull/362))



## [2.1.0] 2023-05-03
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,45 @@

class Command(BaseCommand):

help = "Download annotation data"


help = "Export zipped annotation data to an file."

def add_arguments(self, parser):
parser.add_argument("output_path", type=str, help="Path of file output")
parser.add_argument("project_id", type=str, help="ID of the project")
parser.add_argument("doc_type", type=str, help="Document type all, training, test, or annotation")
parser.add_argument("export_type", type=str, help="Type of export json, jsonl or csv")
parser.add_argument("anonymize", type=self.str2bool, help="Data should be anonymized or not ")
parser.add_argument("-j", "--json_format", type=str, help="Type of json format: raw (default) or gate ")
parser.add_argument("-n", "--num_entries_per_file", type=int, help="Number of entries to generate per file, default 500")
parser.add_argument("-d", "--document_type",
type=str,
help="Document type of either all, training, test, or annotation. Defaults to all.",
choices=["all", "training", "test", "annotation"],
default="all",
metavar="DOCUMENT_TYPE")
parser.add_argument("-e", "--export_type",
type=str,
help="Type of export json, jsonl or csv. Defaults to json.",
choices=["json", "jsonl", "csv"],
default="json",
metavar="EXPORT_TYPE")
parser.add_argument("-a", "--anonymize", type=self.str2bool, default=True,
help="Anonymize data if true. Defaults to true.")
parser.add_argument("-j", "--json_format", type=str, default="raw",
help="Type of json format, raw or gate. Defaults to raw.")
parser.add_argument("-n", "--num_entries_per_file", type=int, default=500,
help="Number of entries to generate per file. Defaults to 500.")


def handle(self, *args, **options):

annotations_downloader = DownloadAnnotationsView()
def handle(self, *args, **options):

output_path = options["output_path"]
project_id = options["project_id"]
doc_type = options["doc_type"]
doc_type = options["document_type"]
export_type = options["export_type"]
anonymize = options["anonymize"]
json_format = options["json_format"] if options["json_format"] else "raw"
num_entries_per_file = options["num_entries_per_file"] if options["num_entries_per_file"] else 500
json_format = options["json_format"]
num_entries_per_file = options["num_entries_per_file"]

print(f"Writing annotations to {output_path} \n Project: {project_id}\n Document type: {doc_type}\n Export type: {export_type} \n Anonymized: {anonymize} \n Json format: {json_format} \n Num entries per file: {num_entries_per_file}\n")
print(f"Writing annotations to: {output_path} \n Project id: {project_id}\n Document type: {doc_type}\n Export type: {export_type} \n Anonymized: {anonymize} \n Json format: {json_format} \n Num entries per file: {num_entries_per_file}\n")

annotations_downloader = DownloadAnnotationsView()
with open(output_path, "wb") as z:
annotations_downloader.write_zip_to_file(file_stream=z,
project_id=project_id,
Expand Down
1 change: 1 addition & 0 deletions docs/docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = context => ({
'releases',
'documentation',
"api_docs",
'commands'

],
},
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/.vuepress/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"text": "2.1.0",
"value": "/gate-teamware/2.1.0/"
},
{
"text": "2.1.1",
"value": "/gate-teamware/2.1.1/"
},
{
"text": "development",
"value": "/gate-teamware/development/"
Expand Down
28 changes: 28 additions & 0 deletions docs/docs/developerguide/commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Utility commands
Django provides various [built-in utility functions](https://docs.djangoproject.com/en/4.2/ref/django-admin/) that can
be accessed from `manage.py` script at the root of the project. A few teamware-specific utility commands have been added
in order to assist with management and development of the application.

To use the custom utility commands, navigate to the app's root folder (with the file `manage.py`) and
run `./manage.py command_name` where `command_name` is the command that you'd like to run. Adding a `-h` argument
prints out the description and all possible options for the command e.g.:

```
./manage.py export_annotations -h
```

## Available commands

### General Usage
- **export_annotations** - Manually export annotations belonging to a project and save it to a zipped file.

### Development
<span style="color:red">**Warning, use of the following functions will modify or reset your database! Ensure your database is backed up
before using them outside of development.**</span>

- **load_test_fixture** - The command loads a pre-defined test fixture. Use without any arguments to see all
available fixtures.
- **check_create_superuser** - Checks whether there's a superuser in the database and creates one if none exists. The
username, password and email are obtained from environment variables `SUPERUSER_USERNAME`, `SUPERUSER_PASSWORD` and
`SUPERUSER_EMAIL` respectively.

4 changes: 4 additions & 0 deletions docs/versioned/0.3.0/.vuepress/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"text": "2.1.0",
"value": "/gate-teamware/2.1.0/"
},
{
"text": "2.1.1",
"value": "/gate-teamware/2.1.1/"
},
{
"text": "development",
"value": "/gate-teamware/development/"
Expand Down
4 changes: 4 additions & 0 deletions docs/versioned/0.4.0/.vuepress/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"text": "2.1.0",
"value": "/gate-teamware/2.1.0/"
},
{
"text": "2.1.1",
"value": "/gate-teamware/2.1.1/"
},
{
"text": "development",
"value": "/gate-teamware/development/"
Expand Down
4 changes: 4 additions & 0 deletions docs/versioned/2.0.0/.vuepress/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"text": "2.1.0",
"value": "/gate-teamware/2.1.0/"
},
{
"text": "2.1.1",
"value": "/gate-teamware/2.1.1/"
},
{
"text": "development",
"value": "/gate-teamware/development/"
Expand Down
4 changes: 4 additions & 0 deletions docs/versioned/2.1.0/.vuepress/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"text": "2.1.0",
"value": "/gate-teamware/2.1.0/"
},
{
"text": "2.1.1",
"value": "/gate-teamware/2.1.1/"
},
{
"text": "development",
"value": "/gate-teamware/development/"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<template>
<div>
<b-tabs>
<b-tab title="Code">

<slot></slot>

</b-tab>
<b-tab title="Preview">
<p v-if="documents.length > 1">Document {{documentIndex + 1}} of {{documents.length}}</p>
<b-card class="mb-2 mt-2">
<AnnotationRenderer ref="annotationRenderer"
:config="config"
:document="currentDocument" :allow_document_reject="true"
v-model="annotationOutput"
:doc_preannotation_field="preAnnotation"
@submit="nextDocument()"
@reject="nextDocument()"
></AnnotationRenderer>
</b-card>
<b-card class="mb-2 mt-2">
<p><strong>Annotation output:</strong></p>
{{annotationOutput}}
</b-card>
</b-tab>

</b-tabs>
</div>

</template>

<script>
import AnnotationRenderer from '@/components/AnnotationRenderer';

export default {
name: "AnnotationRendererPreview",
components: {
AnnotationRenderer
},
data(){
return {
annotationOutput: {},
documentIndex: 0
}

},
computed: {
documents() {
if(Array.isArray(this.document)) {
return this.document
} else {
return [this.document]
}
},
currentDocument() {
return this.documents[this.documentIndex]
}
},
props: {
preAnnotation: {
default(){
return ""
}
},
document: {
default(){
return {text: "Sometext with <strong>html</strong>"}
}
},
config: {
default() {
return [
{
"name": "htmldisplay",
"type": "html",
"text": "{{{text}}}"
},
{
"name": "sentiment",
"type": "radio",
"title": "Sentiment",
"description": "Please select a sentiment of the text above.",
"options": {
"negative": "Negative",
"neutral": "Neutral",
"positive": "Positive"

}
}
]
}
},
},
methods: {
nextDocument() {
this.documentIndex = (this.documentIndex + 1) % this.documents.length;
this.$refs.annotationRenderer.clearForm()
}
}
}
</script>

<style>
legend {
font-weight: bold;
}
</style>
21 changes: 21 additions & 0 deletions docs/versioned/2.1.1/.vuepress/components/DisplayVersion.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<span>{{version_name}}</span>
</template>

<script>
import versionData from "../versions.json"
export default {
name: "DisplayVersion",
computed: {
version_name(){
return versionData.current
}
}


}
</script>

<style scoped>

</style>
43 changes: 43 additions & 0 deletions docs/versioned/2.1.1/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const versionData = require("./versions.json")
const path = require("path");
module.exports = context => ({
title: 'GATE Teamware Documentation',
description: 'Documentation for GATE Teamware',
base: versionData.base,
themeConfig: {
nav: [
{text: 'Home', link: '/'},
{text: 'Annotators', link: '/annotatorguide/'},
{text: 'Managers & Admins', link: '/manageradminguide/'},
{text: 'Developer', link: '/developerguide/'}
],
sidebar: {
'/manageradminguide/': [
"",
"project_management",
"project_config",
"documents_annotations_management",
"annotators_management"
],
'/developerguide/': [
'',
'frontend',
'testing',
'releases',
'documentation',
"api_docs",
'commands'

],
},
},
configureWebpack: {
resolve: {
alias: {
'@': path.resolve(__dirname, versionData.frontendSource)
}
}
},


})
17 changes: 17 additions & 0 deletions docs/versioned/2.1.1/.vuepress/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Vue from 'vue'
import {BootstrapVue, BootstrapVueIcons, IconsPlugin} from 'bootstrap-vue'

import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

Vue.use(BootstrapVue)
Vue.use(BootstrapVueIcons)

export default ({
Vue, // the version of Vue being used in the VuePress app
options, // the options for the root Vue instance
router, // the router instance for the app
siteData // site metadata
}) => {

}
Loading
Loading