Skip to content

Commit e73c74f

Browse files
authored
Add import guards for new extras (#314)
* Add test for installs without extras * Change first installation step * Guard fsspec in seg to poly functions * Update lock file * Roll back changes to circleci job * Bump and changelog
1 parent ef030b9 commit e73c74f

File tree

6 files changed

+43
-16
lines changed

6 files changed

+43
-16
lines changed

.circleci/config.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ jobs:
1515
steps:
1616
- checkout # checkout source code to working directory
1717
- run:
18-
name: Install Environment Dependencies
18+
name: Install Basic Environment Dependencies
1919
command: | # install dependencies
2020
apt-get update
2121
apt-get -y install curl libgeos-dev
2222
pip install --upgrade pip
2323
pip install poetry
24-
poetry install -E metrics
25-
24+
poetry install
25+
- run:
26+
name: Test Imports (extras need to be guarded!)
27+
command: | # Make sure that importing works without extras installed
28+
poetry run python -c 'import nucleus'
29+
- run:
30+
name: Install Extra Dependencies
31+
command: | # install dependencies
32+
poetry install -E metrics -E launch
2633
- run:
2734
name: Black Formatting Check # Only validation, without re-formatting
2835
command: |

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ All notable changes to the [Nucleus Python Client](https://github.com/scaleapi/n
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.13.3](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.13.3) - 2022-06-08
8+
## [0.13.4](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.13.4) - 2022-06-09
9+
10+
### Fixed
11+
- Guard against extras imports
12+
13+
## [0.13.3](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.13.3) - 2022-06-09
914

1015
### Fixed
1116
- Make installation of scale-launch optional (again!).

nucleus/metrics/segmentation_metrics.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import abc
22
from typing import List, Optional, Union
33

4-
import fsspec
54
import numpy as np
65
from PIL import Image
7-
from s3fs import S3FileSystem
6+
7+
try:
8+
import fsspec
9+
from s3fs import S3FileSystem
10+
except ModuleNotFoundError:
11+
from ..package_not_installed import PackageNotInstalled
12+
13+
S3FileSystem = PackageNotInstalled
14+
fsspec = PackageNotInstalled
815

916
from nucleus.annotation import AnnotationList, SegmentationAnnotation
1017
from nucleus.metrics.base import MetricResult

nucleus/metrics/segmentation_to_poly_metrics.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import abc
22
from typing import List, Optional, Union
33

4-
import fsspec
54
import numpy as np
65
from PIL import Image
7-
from s3fs import S3FileSystem
86

97
from nucleus.annotation import AnnotationList
108
from nucleus.metrics.base import MetricResult
@@ -15,6 +13,15 @@
1513
)
1614
from nucleus.prediction import PredictionList
1715

16+
try:
17+
import fsspec
18+
from s3fs import S3FileSystem
19+
except ModuleNotFoundError:
20+
from ..package_not_installed import PackageNotInstalled
21+
22+
S3FileSystem = PackageNotInstalled
23+
fsspec = PackageNotInstalled
24+
1825
from .base import Metric, ScalarResult
1926
from .polygon_metrics import (
2027
PolygonAveragePrecision,

poetry.lock

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exclude = '''
2121

2222
[tool.poetry]
2323
name = "scale-nucleus"
24-
version = "0.13.3"
24+
version = "0.13.4"
2525
description = "The official Python client library for Nucleus, the Data Platform for AI"
2626
license = "MIT"
2727
authors = ["Scale AI Nucleus Team <nucleusapi@scaleapi.com>"]

0 commit comments

Comments
 (0)