Skip to content

Commit 3dd3c64

Browse files
authored
Merge pull request #129 from quantifyearth/mwd-relax-install-requirements
No longer need to pin numpy thanks to GDAL being better
2 parents 192bd14 + 4d571cf commit 3dd3c64

4 files changed

Lines changed: 19 additions & 17 deletions

File tree

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ RUN git clone https://github.com/carboncredits/littlejohn.git
33
WORKDIR littlejohn
44
RUN go build
55

6-
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.8.4
6+
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.10.1
77

88
COPY --from=littlejohn /go/littlejohn/littlejohn /bin/littlejohn
99

@@ -18,14 +18,13 @@ apt-get install -qy \
1818
# You must install numpy before anything else otherwise
1919
# gdal's python bindings are sad. Pandas we full out as its slow
2020
# to build, and this means it'll be cached
21-
RUN pip install --upgrade pip
22-
RUN pip install numpy
23-
RUN pip install gdal[numpy]==3.8.4
21+
RUN pip config set global.break-system-packages true
22+
RUN pip install gdal[numpy]==3.10.1
2423

2524
WORKDIR /usr/src/app
2625
COPY requirements.txt ./
2726
RUN pip install --no-cache-dir -r requirements.txt
2827
COPY . ./
2928
RUN make lint && make type && make test
3029
# Show the dependencies that passed in the log
31-
RUN pip freeze
30+
RUN pip freeze

methods/inputs/locate_gedi_data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
from biomassrecovery.constants import GediProduct # type: ignore
1212
from osgeo import ogr, osr # type: ignore
1313

14+
# you have to import gdal to get the type ogr.DataSource for mypy 🤦
15+
from osgeo import gdal # pylint: disable=W0611
16+
1417
# load environment variables from .env file for Earthdata credentials
1518
dotenv.load_dotenv()
1619
EARTHDATA_USER = os.getenv("EARTHDATA_USER")

methods/utils/dranged_tree.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717

1818
class DRangedTree:
1919
def contains(self, point: np.ndarray):
20-
raise NotImplemented
20+
raise NotImplementedError
2121

2222
def depth(self) -> int:
2323
return 1
24-
24+
2525
def dump(self, space: str) -> None:
26-
raise NotImplemented
27-
26+
raise NotImplementedError
27+
2828
def size(self) -> int:
2929
return 1
30-
30+
3131
@staticmethod
3232
def build(items: np.ndarray, widths: np.ndarray, expected_fraction: float) -> DRangedTree:
3333
"""
@@ -101,7 +101,7 @@ def depth(self):
101101
return 1 + self.subtree.depth()
102102
def size(self):
103103
return 1 + self.subtree.size()
104-
104+
105105
class CheckTree(DRangedTree):
106106
def __init__(self, axis: int, value: float, subtree: DRangedTree, continuation: DRangedTree|None = None):
107107
self.axis = axis
@@ -198,10 +198,10 @@ def __init__(self, dimensions_or_tree: int|TreeState, j: int = -1, drop: bool =
198198

199199
def descend(self, j: int) -> TreeState:
200200
return TreeState(self, j)
201-
201+
202202
def drop(self, j: int) -> TreeState:
203203
return TreeState(self, j, drop=True)
204-
204+
205205
def print(self, s: str) -> None:
206206
if self.logging:
207207
print(self.depth * " ", s)
@@ -247,7 +247,7 @@ def _make_tree_internal(rects: np.ndarray, bounds: np.ndarray, state: TreeState)
247247
sub_bounds = without(bounds, d)
248248
subtree = _make_tree_internal(sub_rects, sub_bounds, state.drop(d))
249249
return FulfilledTree(subtree, d)
250-
250+
251251
# Check if we need to bound a dimension
252252
for d in range(dimensions):
253253
if state.descent[d] == state.bound_dimension_at:
@@ -353,7 +353,7 @@ def make_tree_without_d(d: int, rects):
353353
# Diminishing returns as this parameter is dropped; this seems like reasonable trade-off
354354
# Wherever we split we're hardly going to achieve much, so fall out to a list
355355
return ListTree(rects)
356-
356+
357357
d = best_d
358358
split = splits[d]
359359

@@ -365,7 +365,7 @@ def make_tree_without_d(d: int, rects):
365365
# We can only get here if we're splitting on classes, and there are only two classes,
366366
# so we can simply split at a point between the two classes.
367367
split_at = np.mean(split)
368-
else:
368+
else:
369369
if False and best_classes < 3:
370370
# Chance there is an overlap here, so let's check and eliminate it if possible
371371
# L L L LL LL

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
numpy<2
1+
numpy
22
gdal[numpy]
33
requests
44
pandas

0 commit comments

Comments
 (0)