Skip to content

Conversation

@SaitejaKommi
Copy link

@SaitejaKommi SaitejaKommi commented Jan 8, 2026

Pull Request

Description

The version is retrieved dynamically using importlib.metadata via a small helper (get_version) and displayed on the home page for both:

  • UK Analysis Dashboard
  • India Analysis Dashboard

This avoids hard-coding version strings and ensures the displayed version matches the installed package version in deployed environments.

Fixes #385

How Has This Been Tested?

  • Ran the application locally using:

uv run streamlit run src/main.py

  • Verified that the dashboard renders correctly and the version string is displayed on the homepage.

  • Confirmed expected fallback behaviour (v?) when the package is not installed locally.

  • Yes

If your changes affect data processing, have you plotted any changes?

  • Not applicable (UI-only change)

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@peterdudfield
Copy link
Contributor

Have you tried this when running docker?

@SaitejaKommi
Copy link
Author

Thanks for checking, @peterdudfield .
I haven’t tested this in Docker yet — I’ve only verified it locally via uv run streamlit run src/main.py.
I’ll run the Docker build and confirm whether the version renders correctly there, and update the PR shortly.

@SaitejaKommi
Copy link
Author

Hi @peterdudfield — yes, I’ve now tested this using Docker.

I built the image locally and ran the container, and the version renders correctly on the homepage (v0.1.0) when the package is installed, with the expected fallback when it isn’t.

Happy to adjust if you’d prefer the version placement or formatting to change.
image

@peterdudfield
Copy link
Contributor

The latest git version is v1.0.7. It would be good to show that

@peterdudfield
Copy link
Contributor

You might need to do some changes that are in https://github.com/openclimatefix/analysis-dashboard/pull/385/files

@SaitejaKommi
Copy link
Author

Hi @peterdudfield — quick check:
when testing the Docker build locally, the initial build takes ~20–25 minutes due to the torch + scientific Python dependencies (CPU-only torch).
The build completes successfully and the app runs with the correct version shown (1.0.7).
Just wanted to confirm this build time is expected/acceptable and that there’s nothing else you’d like me to optimise at this stage.

@SaitejaKommi
Copy link
Author

Hi @peterdudfield — thanks for your patience.
I’ve pushed the latest changes and verified everything end-to-end:

Version resolves from git tags (1.0.7)

Docker builds and runs successfully

After login, the Home page displays v1.0.7

All changes are limited to packaging/versioning and Docker reproducibility.
Please let me know if you’d like any adjustments.
image

Dockerfile Outdated
COPY pyproject.toml ./
COPY README.md ./
# Copy full repository INCLUDING .git
COPY . .
Copy link
Contributor

Choose a reason for hiding this comment

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

could you just copy over the files you need please. This helps keep it a bit trimmer

Copy link
Author

Choose a reason for hiding this comment

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

Hi @peterdudfield , I’ve pushed an update that resolves the dashboard version directly from the installed package using importlib.metadata.version("analysis-dashboard"), and simplified the Docker build to only copy the files needed.

This removes the need for a separate directory just for versioning and shows the latest git-tagged version (v1.0.7).
Happy to adjust if you’d prefer a different pattern.

@peterdudfield
Copy link
Contributor

Is there any way to do this, where you dont have to create a sepearate dir for analys-dasboad just for versions

@SaitejaKommi
Copy link
Author

Is there any way to do this, where you dont have to create a sepearate dir for analys-dasboad just for versions

Hi @peterdudfield I pushed a follow-up commit that removes the package-based version approach and instead reads the version directly from importlib.metadata.
This avoids having a separate directory just for versioning and keeps git tags as the single source of truth.
The dashboard now shows v1.0.7 locally and in Docker.

Please let me know if you’d like any adjustments.

image

src/main.py Outdated
st.text(
"This is the Analysis Dashboard UK. "
"Please select the page you want from the menu at the top of this page"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you remove this from the metric page? I dont think this is needed

from batch_page import batch_page

st.get_option("theme.primaryColor")
st.set_page_config(layout="wide", page_title="OCF Dashboard")
Copy link
Contributor

@peterdudfield peterdudfield Jan 19, 2026

Choose a reason for hiding this comment

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

can you role this change back?

Copy link
Contributor

@peterdudfield peterdudfield Jan 19, 2026

Choose a reason for hiding this comment

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

can you remove the comment in the code

"fiona>=1.9,<2.0",
"herbie-data",
"numcodecs>=0.12,<1.0",
"torch @ https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp312-cp312-linux_x86_64.whl ; platform_system == 'Linux' and platform_machine == 'x86_64'",
Copy link
Contributor

Choose a reason for hiding this comment

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

can you role this change back please?

Copy link
Contributor

Choose a reason for hiding this comment

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

please remove comment, thats not needed

Copy link
Contributor

Choose a reason for hiding this comment

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

remove # comment, its not needed

"pytest",
"pytest-cov",
"ruff",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

why has this been removed?

Copy link
Author

Choose a reason for hiding this comment

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

I was restructuring the packaging while debugging the versioning issue and accidentally removed the [tool.uv].dev-dependencies block while consolidating configuration. There was no intention to drop the dev tooling. I’ve restored the following so local development and CI continue to work as before:

Copy link
Contributor

Choose a reason for hiding this comment

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

why have you not put it back in then?

Copy link
Contributor

@peterdudfield peterdudfield left a comment

Choose a reason for hiding this comment

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

Thanks for this, I think there are few chagnes that are unnecessary, could you role thsoe back please?

@SaitejaKommi
Copy link
Author

Thanks for this, I think there are few chagnes that are unnecessary, could you role thsoe back please?

Thanks @peterdudfield , I’ve rolled back the unnecessary dependency and config changes, restored the original torch handling and dev dependencies, and kept the version display minimal without introducing a separate package. Please let me know if this looks better now.
Sorry about the unnecessary changes earlier,
I had initially missed that this text belonged to the metrics page and added it in the wrong place.
I’ve now reverted those changes and only updated main.py to display the package version on the home page.

# Remove git metadata after install (keeps image small)
RUN rm -rf .git

EXPOSE 5433
Copy link
Contributor

Choose a reason for hiding this comment

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

why have you removed exposing port 5433?

- "8501:8501" # Mapping the Streamlit port
- "5433:5433" # Database port (if necessary)
- "8501:8501"
- "5433:5433"
Copy link
Contributor

Choose a reason for hiding this comment

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

can you role these changes back please?

DB_URL: ${DB_URL:-}
PASSWORD: ${PASSWORD:-example}
AUTH0_CLIENT_ID: ${AUTH0_CLIENT_ID:-}
AUTH0_DOMAIN: ${AUTH0_DOMAIN:-}
Copy link
Contributor

Choose a reason for hiding this comment

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

why have you changes this?

Copy link
Author

Choose a reason for hiding this comment

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

Sincere apologies for the noise on this PR.

I realise I made several changes that went beyond the original scope, which caused unnecessary confusion and extra review effort. That wasn’t my intention, and I’m sorry for the back-and-forth it created.

I’ve now taken a step back, reviewed the original code carefully, and understand where I went wrong. Before pushing the next update, I wanted to acknowledge this and thank you for your patience and clear feedback.

I’ll keep the upcoming changes minimal, scoped, and aligned with upstream expectations.

@SaitejaKommi
Copy link
Author

Thanks a lot @peterdudfield 🙏 for your patience here, and sorry for the noise in the earlier updates.

I realised I’d bundled a few unrelated changes together while iterating locally (Docker, compose comments, and some config tweaks), which wasn’t ideal. I’ve now rolled those back so this PR is focused only on the intended change:

Displaying the package version on the dashboard home page using importlib.metadata, without adding a separate version module or package.

Removing the extra text from the metrics page as suggested.

Restoring the original Dockerfile and docker-compose behaviour (ports, env vars, and comments) to match upstream.

I’ve also cleaned up the commit history to avoid duplicate commit messages.

Thanks again for the review and guidance — let me know if you’d like anything adjusted further

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants