Skip to content

Commit

Permalink
Merge pull request #43 from inception-project/feature-42-check-for-pa…
Browse files Browse the repository at this point in the history
…ckage-updates

Feature 42 check for package updates
  • Loading branch information
serwarde authored Jun 10, 2024
2 parents 6cd5736 + 414cccc commit a54521b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.idea
inception_reports.egg-info
__pycache__
/data
/sample_project
.vscode/settings.json
*.ipynb
/build
Expand Down
4 changes: 2 additions & 2 deletions inception_reports/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def main():
)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"--manager", help="You are managing a single project, or a single location.", action="store_true"
"-m", "--manager", help="You are managing a single project, or a single location.", action="store_true"
)
group.add_argument("--lead", help="You are leading multiple projects, or multiple locations.", action="store_true")
group.add_argument("-l", "--lead", help="You are leading multiple projects, or multiple locations.", action="store_true")

args = parser.parse_args()

Expand Down
39 changes: 38 additions & 1 deletion inception_reports/generate_reports_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import copy
import importlib.resources
import json
import os
import shutil
Expand All @@ -24,11 +25,13 @@

import cassis
import pandas as pd
import pkg_resources
import plotly.express as px
import plotly.graph_objects as go
import requests
import streamlit as st
import toml
from pycaprio import Pycaprio
import importlib.resources

st.set_page_config(
page_title="INCEpTION Reporting Dashboard",
Expand Down Expand Up @@ -72,6 +75,40 @@ def startup():
unsafe_allow_html=True,
)

project_info = get_project_info()
if project_info:
current_version, package_name = project_info
latest_version = check_package_version(current_version, package_name)
if latest_version:
st.sidebar.warning(
f"A new version ({latest_version}) of {package_name} is available. "
f"You are currently using version ({current_version}). Please update the package."
)

def get_project_info():
try:
pyproject_path = os.path.join(os.path.dirname(__file__), '..', 'pyproject.toml')
with open(pyproject_path, 'r') as f:
pyproject_data = toml.load(f)
version = pyproject_data["project"].get("version")
name = pyproject_data["project"].get("name")
if version and name:
return version, name
return None
except (FileNotFoundError, KeyError):
return None


def check_package_version(current_version, package_name):
try:
response = requests.get(f"https://pypi.org/pypi/{package_name}/json", timeout=5)
if response.status_code == 200:
latest_version = response.json()["info"]["version"]
if pkg_resources.parse_version(current_version) < pkg_resources.parse_version(latest_version):
return latest_version
except requests.RequestException:
return None
return None

def create_directory_in_home():
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "inception_reports"
description = "Generate plots that report the progress of an INCEpTION project."
version = "0.5"
version = "0.5.1"
authors = [
{ name = "Serwar", email = "[email protected]" }
]
Expand Down

0 comments on commit a54521b

Please sign in to comment.