Skip to content

Commit 1d7b194

Browse files
author
Leo Lindén
authored
Merge pull request #4 from superannotateai/develop
Develop
2 parents 6501c1a + a0f8911 commit 1d7b194

17 files changed

+86
-12
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
2+
3+
on:
4+
release:
5+
types: [prereleased,released]
6+
7+
jobs:
8+
build-n-publish:
9+
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: "3.8"
17+
- name: Upgrade pip
18+
run: >-
19+
python -m
20+
pip install
21+
pip --upgrade
22+
--user
23+
- name: Install pypi/build
24+
run: >-
25+
python -m
26+
pip install
27+
build
28+
--user
29+
- name: Build a binary wheel and a source tarball
30+
run: >-
31+
python -m
32+
build
33+
--sdist
34+
--wheel
35+
--outdir dist/
36+
.
37+
- name: Publish distribution 📦 to PyPI
38+
if: startsWith(github.ref, 'refs/tags')
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
with:
41+
password: ${{ secrets.pypi_password }}
42+
verbose: true

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name = "superannotate_databricks_connector" # Required
44

5-
version = "0.0.1dev1"
5+
version = "0.0.2dev1"
66

77
description = "Custom functions to work with SuperAnnotate in Databricks"
88

readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ If you are running the tests for the first you first have to build the base dock
3434
docker build -f Dockerfile.spark -t spark_docker_base .
3535
```
3636

37+
### Build package
38+
39+
In the main directory, run the following to generate a .whl file.
40+
41+
```bash
42+
python -m build
43+
```
44+
3745
### Usage
3846
First import the required function
3947

src/superannotate_databricks_connector/schemas/text_schema.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def get_text_schema():
4242
schema = StructType([
4343
StructField("name", StringType(), True),
4444
StructField("url", StringType(), True),
45-
StructField("contentLength", IntegerType(), True),
4645
StructField("projectId", IntegerType(), True),
4746
StructField("status", StringType(), True),
4847
StructField("annotatorEmail", StringType(), True),

src/superannotate_databricks_connector/schemas/vector_schema.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ def get_vector_instance_schema():
5959
return instance_schema
6060

6161

62+
def get_vector_tag_schema():
63+
schema = StructType([
64+
StructField("instance_type", StringType(), True),
65+
StructField("classId", IntegerType(), True),
66+
StructField("probability", IntegerType(), True),
67+
StructField("attributes", ArrayType(MapType(StringType(),
68+
StringType())),
69+
True),
70+
StructField("createdAt", StringType(), True),
71+
StructField("createdBy", MapType(StringType(), StringType()), True),
72+
StructField("creationType", StringType(), True),
73+
StructField("updatedAt", StringType(), True),
74+
StructField("updatedBy", MapType(StringType(), StringType()), True),
75+
StructField("className", StringType(), True)])
76+
return schema
77+
78+
6279
def get_vector_schema():
6380
schema = StructType([
6481
StructField("image_height", IntegerType(), True),
@@ -73,6 +90,7 @@ def get_vector_schema():
7390
StructField("instances", ArrayType(get_vector_instance_schema()),
7491
True),
7592
StructField("bounding_boxes", ArrayType(IntegerType()), True),
76-
StructField("comments", ArrayType(get_comment_schema()), True)
93+
StructField("comments", ArrayType(get_comment_schema()), True),
94+
StructField("tags", ArrayType(get_vector_tag_schema()), True)
7795
])
7896
return schema

src/superannotate_databricks_connector/text.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from datetime import datetime
2-
from superannotate_databricks_connector.schemas.text_schema import get_text_schema
2+
from superannotate_databricks_connector.schemas.text_schema import (
3+
get_text_schema
4+
)
35

46

57
def convert_dates(instance):
@@ -40,7 +42,6 @@ def get_text_dataframe(annotations, spark):
4042
flattened_item = {
4143
"name": item["metadata"]["name"],
4244
"url": item["metadata"]["url"],
43-
"contentLength": item["metadata"]["contentLength"],
4445
"projecId": item["metadata"]["projectId"],
4546
"status": item["metadata"]["status"],
4647
"annotatorEmail": item["metadata"]["annotatorEmail"],

src/superannotate_databricks_connector/vector.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from superannotate_databricks_connector.schemas.vector_schema import get_vector_schema
1+
from superannotate_databricks_connector.schemas.vector_schema import (
2+
get_vector_schema
3+
)
24

35

46
def process_comment(comment):
@@ -140,7 +142,7 @@ def get_vector_dataframe(annotations, spark, custom_id_map=None):
140142
'qaEmail': item["metadata"]['qaEmail'],
141143
"instances": [process_vector_object(instance, custom_id_map)
142144
for instance in item["instances"]
143-
if instance["type"] == "object"],
145+
if instance["type"] != "tag"],
144146
"bounding_boxes": get_boxes(item["instances"], custom_id_map),
145147
"tags": [process_vector_tag(instance, custom_id_map)
146148
for instance in item["instances"]
-8 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)