Skip to content

Commit

Permalink
Dropping Python 3.8, add support for 3.12 & 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie committed Nov 18, 2024
1 parent 364f2ce commit 1e692c4
Show file tree
Hide file tree
Showing 15 changed files with 1,392 additions and 996 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/JOB_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
python-version: ["3.11"]
poetry-version: ["1.3.1"]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/JOB_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set up Python environment
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.11"
python-version: "3.12"

- name: Show filenames
run: echo ${{ inputs.files }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/JOB_generate_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/JOB_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Set up Python environment
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.10"
python-version: "3.11"

- name: Show filenames
run: echo ${{ inputs.files }}
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/JOB_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
exclude:
- os: macos-latest
python-version: "3.8"
- os: macos-latest
python-version: "3.9"
include:
- os: macos-13
python-version: "3.8"
- os: macos-13
python-version: "3.9"
# include:
# - os: macos-13
# python-version: "3.9"
runs-on: ${{ matrix.os }}
steps:
- name: Harden Runner
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/JOB_typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set up Python environment
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.10"
python-version: "3.11"

- name: Show filenames
run: echo ${{ inputs.files }}
Expand Down
12 changes: 8 additions & 4 deletions darwin/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,17 @@ def __init__(
super().__init__("Complex polygons not yet supported for dataloop import")


class ExportException(DarwinException): ...
class ExportException(DarwinException):
...


class ExportException_CouldNotAssembleOutputPath(ExportException): ...
class ExportException_CouldNotAssembleOutputPath(ExportException):
...


class ExportException_CouldNotBuildOutput(ExportException): ...
class ExportException_CouldNotBuildOutput(ExportException):
...


class ExportException_CouldNotWriteFile(ExportException): ...
class ExportException_CouldNotWriteFile(ExportException):
...
3 changes: 2 additions & 1 deletion darwin/future/core/types/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@


class Implements_str(Protocol):
def __str__(self) -> str: ...
def __str__(self) -> str:
...


Stringable = Union[str, Implements_str]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
class InvalidValueForTest: ...
class InvalidValueForTest:
...
67 changes: 34 additions & 33 deletions darwin/importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ def _get_team_properties_annotation_lookup(
team_properties = client.get_team_properties(team_slug)

# (property-name, annotation_class_id): FullProperty object
team_properties_annotation_lookup: Dict[Tuple[str, Optional[int]], FullProperty] = (
{}
)
team_properties_annotation_lookup: Dict[
Tuple[str, Optional[int]], FullProperty
] = {}

# property-name: FullProperty object
team_item_properties_lookup: Dict[str, FullProperty] = {}
Expand All @@ -317,9 +317,9 @@ def _get_team_properties_annotation_lookup(
prop.granularity.value == "section"
or prop.granularity.value == "annotation"
):
team_properties_annotation_lookup[(prop.name, prop.annotation_class_id)] = (
prop
)
team_properties_annotation_lookup[
(prop.name, prop.annotation_class_id)
] = prop
elif prop.granularity.value == "item":
team_item_properties_lookup[prop.name] = prop

Expand Down Expand Up @@ -499,9 +499,10 @@ def _import_properties(
metadata_property_classes, metadata_item_props = _parse_metadata_file(metadata_path)

# Get team properties
team_properties_annotation_lookup, team_item_properties_lookup = (
_get_team_properties_annotation_lookup(client, dataset.team)
)
(
team_properties_annotation_lookup,
team_item_properties_lookup,
) = _get_team_properties_annotation_lookup(client, dataset.team)

# Build metadata lookups
(
Expand Down Expand Up @@ -748,12 +749,13 @@ def _import_properties(
].add(t_prop_val.id)

# Create/Update team item properties based on metadata
item_properties_to_create_from_metadata, item_properties_to_update_from_metadata = (
_create_update_item_properties(
_normalize_item_properties(metadata_item_prop_lookup),
team_item_properties_lookup,
client,
)
(
item_properties_to_create_from_metadata,
item_properties_to_update_from_metadata,
) = _create_update_item_properties(
_normalize_item_properties(metadata_item_prop_lookup),
team_item_properties_lookup,
client,
)

console = Console(theme=_console_theme())
Expand Down Expand Up @@ -804,9 +806,10 @@ def _import_properties(
updated_properties.append(prop)

# get latest team properties
team_properties_annotation_lookup, team_item_properties_lookup = (
_get_team_properties_annotation_lookup(client, dataset.team)
)
(
team_properties_annotation_lookup,
team_item_properties_lookup,
) = _get_team_properties_annotation_lookup(client, dataset.team)

# Update item-level properties from annotations
_, item_properties_to_update_from_annotations = _create_update_item_properties(
Expand Down Expand Up @@ -835,9 +838,10 @@ def _import_properties(
updated_properties.append(prop)

# get latest team properties
team_properties_annotation_lookup, team_item_properties_lookup = (
_get_team_properties_annotation_lookup(client, dataset.team)
)
(
team_properties_annotation_lookup,
team_item_properties_lookup,
) = _get_team_properties_annotation_lookup(client, dataset.team)

# loop over metadata_cls_id_prop_lookup, and update additional metadata property values
for (annotation_class_id, prop_name), m_prop in metadata_cls_id_prop_lookup.items():
Expand Down Expand Up @@ -987,7 +991,6 @@ def _create_update_item_properties(

# If the property exists in the team, check that all values are present
if item_prop_name in team_item_properties_lookup:

t_prop = team_item_properties_lookup[item_prop_name]
# If the property is a text property it won't have predefined values, so continue
if t_prop.type == "text":
Expand All @@ -1014,7 +1017,6 @@ def _create_update_item_properties(

# If the property does not exist in the team, create it
else:

# If we've already planned to create this property, simply extend the property values
for prop in create_properties:
if prop.name == item_prop_name:
Expand Down Expand Up @@ -1829,9 +1831,9 @@ def _import_annotations(
# Insert the default slot name if not available in the import source
annotation = _handle_slot_names(annotation, dataset.version, default_slot_name)

annotation_class_ids_map[(annotation_class.name, annotation_type)] = (
annotation_class_id
)
annotation_class_ids_map[
(annotation_class.name, annotation_type)
] = annotation_class_id
serial_obj = {
"annotation_class_id": annotation_class_id,
"data": data,
Expand Down Expand Up @@ -1945,9 +1947,9 @@ def _overwrite_warning(

# Check if the item has item-level properties that will be overwritten
if local_file.item_properties:
response: Dict[str, List[Dict[str, str]]] = (
client.api_v2._get_properties_state_for_item(item_id, dataset.team)
)
response: Dict[
str, List[Dict[str, str]]
] = client.api_v2._get_properties_state_for_item(item_id, dataset.team)
item_property_ids_with_populated_values = [
property_data["id"]
for property_data in response["properties"]
Expand All @@ -1957,7 +1959,6 @@ def _overwrite_warning(
files_with_item_properties_to_overwrite.append(local_file.full_path)

if files_with_annotations_to_overwrite or files_with_item_properties_to_overwrite:

# Overwriting of annotations
if files_with_annotations_to_overwrite:
console.print(
Expand Down Expand Up @@ -2242,9 +2243,9 @@ def _split_payloads(
)
payloads.append(current_payload)
current_payload = copy.deepcopy(base_payload)
current_payload["overwrite"] = (
False # Required to make sure subsequent payloads don't overwrite previous ones
)
current_payload[
"overwrite"
] = False # Required to make sure subsequent payloads don't overwrite previous ones
current_payload["annotations"].append(annotation)
current_payload_size = annotation_size

Expand Down
17 changes: 9 additions & 8 deletions e2e_tests/cli/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,15 @@ def compare_annotations_export(
actual_filename = get_actual_annotation_filename(
expected_filename, actual_annotation_files
)
expected_annotation_data, actual_annotation_data = (
parse_expected_and_actual_annotations(
expected_annotation_files,
actual_annotation_files,
expected_filename,
actual_filename,
annotation_format,
)
(
expected_annotation_data,
actual_annotation_data,
) = parse_expected_and_actual_annotations(
expected_annotation_files,
actual_annotation_files,
expected_filename,
actual_filename,
annotation_format,
)
for idx, expected_annotation_file in enumerate(expected_annotation_data):
actual_annotation_file = actual_annotation_data[idx]
Expand Down
Loading

0 comments on commit 1e692c4

Please sign in to comment.