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

Update packages and methods for 2024 #384

Merged
merged 10 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 1 addition & 1 deletion .ghsci_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.4.8
4.4.9
2 changes: 1 addition & 1 deletion .test-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
ghsci:
image: globalhealthyliveablecities/global-indicators:v4.4.8
image: globalhealthyliveablecities/global-indicators:v4.4.9
container_name: ghsci
shm_size: 2g
stdin_open: true # docker run -i
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
ghsci:
image: globalhealthyliveablecities/global-indicators:v4.4.8
image: globalhealthyliveablecities/global-indicators:v4.4.9
container_name: ghsci
shm_size: 2g
stdin_open: true # docker run -i
Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##############################################################################
##############################################################################
# Build an image from the dockerfile:
# >>> docker build -t globalhealthyliveablecities/global-indicators:latest .
#
Expand All @@ -18,7 +18,7 @@
# >>> docker rmi $(docker images -q) --force
##############################################################################

FROM continuumio/miniconda3:23.3.1-0-alpine as build
FROM continuumio/miniconda3:23.10.0-1 as build
LABEL maintainer="Global Healthy Liveable City Indicator Study Collaboration Group"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to pin the version number that precisely? Can we just use latest here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gboeing, that's a good question -- perhaps we can. From memory, the reason I did a specific version at the time was, that was the latest release that supported Arm64. Previously, I had used the 'alpine' image, which is smaller size, but doesn't reliably support arm64 (mostly only amd64). Perhaps that is why the alpine image is half the size though. If you believe the 'latest' miniconda3 reliably supports arm64, and using 'latest' is unlikely to introduce incompatibilities, I can't see why not (they just released an updated version 3 days ago, so already advanced since pull request lodged).

I'll look to updating this after I hear back comments from others later in the week, in case there are other things to shift.

LABEL url="https://github.com/global-healthy-liveable-cities/global-indicators"

Expand All @@ -39,7 +39,7 @@ RUN conda config --set show_channel_urls true && \

# =============================================================================
# Runtime environment
FROM debian:bullseye-slim as runtime
FROM debian:stable-slim as runtime

# Install the environment pack
COPY --from=build /env.tar.gz .
Expand Down
9 changes: 7 additions & 2 deletions docker/docker-build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ echo.
set "DOCKERUSER=globalhealthyliveablecities"
set "PACKAGE=global-indicators"
for /f "usebackq" %%x in ("%CD%\..\.ghsci_version") do set VERSION=%%x
echo %PACKAGE% version %VERSION%
:: login and remove any existing containers or images
docker login

:: build the image and export the conda env to yml
:: build test image and export the conda env to yml
docker build -t %DOCKERUSER%/%PACKAGE% .
docker run --rm -it --shm-size=2g --net=host -v "%CD%":/home/ghsci globalhealthyliveablecities/global-indicators /bin/bash -c "pip list --format=freeze > ./requirements.txt"
docker run --rm -it --shm-size=2g --net=host -v "%CD%":/home/ghsci %DOCKERUSER%/%PACKAGE% /bin/bash -c "pip list --format=freeze > ./requirements.txt"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set --shm-size here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is because this 'docker run' command is launching the container using a historical snippet of code, overriding the deafult size that was (or perhaps was?) 64mb, since that would not be sufficient to adequately/reliably analyse most cities. However --- good point that in that particular context, setting shm-size isn't necessary, since all that the code is doing there is launching the container to grab a copy of the specific package versions that were installed and output requirements.txt. So I can remove that there, as its not intended to perform any analyses.

shm_size is set for analysis purposes in the compose yml now --- still to 2gb, although, for users with sufficient memory analysing larger cities, they may want/need to increase that:
https://github.com/global-healthy-liveable-cities/global-indicators/blob/931579fc4d375ac8dad25a532256ac84741f6745/docker-compose.yml#L6

Re: the batch file for building the docker image, I'll make a note to edit this later in the week. If you think the setting is no longer required in the compose file, feel free to let me know.


:: built multi-platform image
docker buildx create --use
docker buildx build --platform=linux/amd64,linux/arm64 -t %DOCKERUSER%/%PACKAGE%:v%VERSION% .

:: get the package version, tag the image with it, then push to hub
echo %PACKAGE% version %VERSION%
Expand Down
20 changes: 12 additions & 8 deletions docker/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ channels:
- conda-forge
dependencies:
- python
- osmnx=1.5.* # for constructing network graph from OpenStreetMap using Overpass API
- osmnx=1.5.*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.9.* is the latest minor release as of now, if it's worth upgrading this dep

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could give it a go --- it may have been I pinned to 1.5.* to avoid refactoring code due to other changes in dependencies (I tried to make software as new as possible, while re-writing code as least as possible). As above, I'll try the update and see how that goes with other dependencies/refactoring later in the week.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reflecting on this, your time is best served holding off on this one for now. We're working on some deprecations in advance of OSMnx v2 later this year. If it will require some refactoring in our codebase here to upgrade anyway, then we should just hold off until those deprecations for the OSMnx v2 API are all in place in a couple of months. That is, if you have to do some refactoring anyway, then might as well wait to just do it all at once rather than piecemeal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good @gboeing; thanks for heads up. I am sure there will be more patches requiring updates here by that stage in any case, so will be a good opportunity to review things at that point and see if we can better leverage OSMnx functionality and related packages and drop some other dependencies perhaps.

- pandas=2.1.*
- fpdf2=2.7.*
- sqlalchemy=1.4.*
- nicegui>=1.2.24
- cryptography>=41.0.2
- nicegui=1.4.13
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of these deps are pinned down to the patch. Can we pin to the minor version instead? Patches should always be compatible across a minor version, and it would allow installers to bring in any important fixes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicegui is under rapid development (which is good) and they seem to change syntax regularly (can be a bit frustrating). I guess I was being explicit about which version I had designed our code to work with. For other packages, I was following dependabot recommendations.

But having said that, if you think that would be better practice, lets give it a go. As above, I'll aim to build another version of the image later in the week in case there is further feedback.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gboeing I just had a quick go at rebuilding the image removing the minor version pins; as expected, the web app didn't function with this modification (it doesn't load, due to a bug introduced in a recent minor patch zauberzeug/nicegui#2641 ). Its possible other incompatibilities / syntax changes could have been introduced too by one or other packages (even if they shouldn't). But the current selection of versions works for the Docker image according to my tests.

Given the current 4.4.9 build works, and we'll do a further environment update in a few months with OSMnx 2.0, I'm thinking the following:

  • merge this branch into main now, and do a new release
  • any reviewed and tested changes from @dapugacheva and @rychennn based off this image can then also be merged into main
  • I'll then merge main changes into enhancements (or a branch off that, while I work through them to ensure it remains functional).
  • We arrange for translations of report prose once this is finalised (I believe it should be soon)
  • I'll update reporting templates, so those who want to use new templates in English can use Enhancements branch
  • Once we have translations we can merge enhancements into main finally,
  • then we can do a 4.5.0 release

then we'll look for a more thorough update of packages/environment and refactor code and do a 5.0 release then, perhaps?

For now, are you okay with the merging of this branch as is?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sounds like a reasonable plan.

- cryptography=42.0.2
- requests=2.31.*
- tornado>=6.3.2
- starlette>=0.27.0
- pyrosm # for building network graphs from OpenStreetMap .pbf files
- momepy # for building network graphs from external network files
- tornado>=6.3.3
- fonttools=4.43.0
- jupyterlab=4.0.12
- jupyter-lsp=2.2.2
- urllib3=2.0.7
- pillow=10.2.0
- pip>=24.*
- pyrosm=0.6.2
- openpyxl
- babel
- cartopy
Expand All @@ -27,4 +32,3 @@ dependencies:
- tqdm
- pyyaml
- websockets
- pip
Loading
Loading