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

UIP-47: Misc tidying #3558

Merged
merged 2 commits into from
Jun 11, 2024
Merged

UIP-47: Misc tidying #3558

merged 2 commits into from
Jun 11, 2024

Conversation

ialarmedalien
Copy link
Collaborator

@ialarmedalien ialarmedalien commented Jun 7, 2024

Description of PR purpose/changes

Some miscellaneous fixes and so on that I made over the last day or so. Includes:

  • moved the python-requirements file into src/ so it's easier to update py dependencies;
  • edited the dockerfile so it transfers over only the files/folders that it uses, instead of copying over the whole repo; this also makes it quicker to build images locally as more steps can be cached;
  • updated some documentation;
  • added typing/brief docs to some python files.

Jira Ticket / Issue

Related Jira ticket: https://kbase-jira.atlassian.net/browse/UIP-47

  • Added the Jira Ticket to the title of the PR (e.g. DATAUP-69 Adds a PR template)

Testing Instructions

  • Details for how to test the PR:
  • Tests pass locally and in GitHub Actions
  • Changes available by spinning up a local narrative and navigating to X to see Y

Dev Checklist:

  • My code follows the guidelines at https://sites.google.com/lbl.gov/trussresources/home?authuser=0
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • (JavaScript) I have run Prettier and ESLint on changed code manually or with a git precommit hook
  • (Python) I have run Ruff format and check on changed Python code manually or with a git precommit hook
  • Any dependent changes have been merged and published in downstream modules

Updating Version and Release Notes (if applicable)

…src/ folder for ease of updating, and updating the docs accordingly.

also added some typing to some python files
edited dockerfile to transfer over individual folders instead of copying the whole repo and creating an image with a load of unnecessary junk in it.
@ialarmedalien ialarmedalien requested a review from briehl June 7, 2024 20:47
@ialarmedalien ialarmedalien self-assigned this Jun 7, 2024
Comment on lines -16 to -25
- package-ecosystem: pip
directory: "/docker_image_dependencies"
schedule:
interval: monthly
time: '11:00'
groups:
docker-image-python-deps:
patterns:
"*"
open-pull-requests-limit: 20
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all the requirements files are now in the /src directory, so 🤞 dependabot will be a bit more dependable in reporting updates

WORKDIR /kb/dev_container/narrative

RUN mkdir -p /kb/deployment/ui-common/ && \
mkdir -p /tmp/narrative && \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just moved up from the end of this section

# Compile Javascript down into an itty-bitty ball unless SKIP_MINIFY is non-empty
echo Skip="$SKIP_MINIFY" && \
[ -n "$SKIP_MINIFY" ] || npm run minify && \
# install the narrative and jupyter console
# Generate a version file that we can scrape later
./src/scripts/kb-update-config -f src/config.json.templ -o /kb/deployment/ui-common/narrative_version && \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved a little later in the block for ease of development

@@ -56,7 +56,7 @@ This is built on the Jupyter Notebook v6.5.6 and IPython 8.25.0 (more notes will
- scikit-learn: 1.2.1 -> 1.5.0
- statsmodels: 0.14.2 (new)
- terminado: 0.17.1 -> 0.18.0
- tornado: 6.2 -> 6.4
- tornado: 6.2 -> 6.4.1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Of course there's another update just when I thought I had all the python stuff done...

Copy link
Member

Choose a reason for hiding this comment

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

😬

@@ -1,30 +1,32 @@
## Building Narrative Images with Dockerhub
(Updated 6/1/2018)

We currently make use of Travis and Dockerhub (https://hub.docker.com) to manage Narrative production builds. There are three images here that stack on each other.
We currently make use of GitHub Actions and the GitHub Packages (aka the GitHubContainer Repository, https://ghcr.io) to manage Narrative production builds. The narrative comprises two images (to facilitate reasonable narrative build times) and a third tiny image for the narrative version.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

started updating this documentation; will do some more on it when I get this ui-assets thing sorted out


### How to build images
Travis-CI is used to run regression testing on the branches declared in the branches stanza of the top level travis.yml file. Currently the travis file builds on these branches:

GitHub Actions is used to run regression testing on the branches declared in the branches stanza of the top level travis.yml file. Currently the travis file builds on these branches:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Enthusiasm/energy for documentation ran out here.

Comment on lines -9 to -10
NAR_BASE="kbase/narrbase"
NAR_BASE_VER="7.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

doesn't exist

Copy link
Member

Choose a reason for hiding this comment

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

Not anymore it doesn't!

@@ -58,21 +56,6 @@ mkdir -p $WEBROOT_DIR
./src/scripts/kb-update-config -f src/config.json.templ -o $WEBROOT_DIR/narrative_version -e $env -d $dev_mode || exit 1
cp kbase-extension/static/kbase/config/data_source_config.json $WEBROOT_DIR/data_source_config.json

# Make sure the base image is there. If not, build it.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all refers to the narrbase image, which is no longer with us.

@@ -8,12 +8,10 @@
PYTHON=python

SCRIPT_TGT="kbase-narrative"
SCRIPT_TGT2="headless-narrative"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this script exists but it points at a python file that no longer does ==> delete the code so that people aren't tempted to try it

@@ -105,8 +106,8 @@ class KBaseWSManager(KBaseWSManagerMixin, ContentsManager):
# a safety net
wsid_regex = re.compile(r"[\W]+", re.UNICODE)

def __init__(self, *args, **kwargs):
"""Verify that we can connect to the configured WS instance"""
def __init__(self: "KBaseWSManager", *args, **kwargs) -> None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all typing changes here

def dir_exists(self, path):
"""If it's blank, just return True -
def dir_exists(self: "KBaseWSManager", path: str) -> bool:
"""Returns a boolean indicating whether a directory exists.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

getting fancy -- typing AND some basic documentation!

nar_id = "ws.{}.obj.{}".format(nar["wsid"], nar["objid"])
model = base_model("{} - {} - {}".format(nar["saved_by"], nar_id, nar["name"]), nar_id)
def _wsobj_to_model(self: "KBaseWSManager", nar, content: bool = True) -> dict[str, Any]:
nar_id = f"ws.{nar['wsid']}.obj.{nar['objid']}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

use f"..." instead of string.format

@@ -1,7 +1,9 @@
"""Utils for implementing the KBase Narrative manager."""

from typing import Any
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all typing

@@ -6,9 +6,11 @@
import json
import re
from collections import Counter
from typing import Any
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

typing additions

@@ -9,4 +9,4 @@ pyyaml==6.0.1
requests==2.32.3
scikit-learn==1.5.0
statsmodels==0.14.2
tornado==6.4
tornado==6.4.1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated package

Copy link

sonarcloud bot commented Jun 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarCloud

Copy link

codecov bot commented Jun 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 25.74%. Comparing base (aa67a64) to head (b5cf3ac).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3558      +/-   ##
===========================================
- Coverage    29.70%   25.74%   -3.97%     
===========================================
  Files          496      461      -35     
  Lines        50444    46694    -3750     
===========================================
- Hits         14984    12021    -2963     
+ Misses       35460    34673     -787     

see 36 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b401562...b5cf3ac. Read the comment docs.

ADD ./deployment/ /kb/deployment/
WORKDIR /kb/dev_container/narrative
ADD ./build.js /kb/dev_container/narrative/
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copying over the directories and files that are actually used, instead of everything under the sun. Attempted to order them by approximate likelihood of being changed, although everything after nbextensions is a lot more likely to be edited than the stuff before it.

Copy link
Member

Choose a reason for hiding this comment

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

Good idea. Eventually (not this PR, and maybe not right away) it might be nice to make a production-only image and leave out tests, test data, test-only dependencies, and so on.

But this is a good step on that path!

Copy link
Member

@briehl briehl left a comment

Choose a reason for hiding this comment

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

👍

ADD ./deployment/ /kb/deployment/
WORKDIR /kb/dev_container/narrative
ADD ./build.js /kb/dev_container/narrative/
Copy link
Member

Choose a reason for hiding this comment

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

Good idea. Eventually (not this PR, and maybe not right away) it might be nice to make a production-only image and leave out tests, test data, test-only dependencies, and so on.

But this is a good step on that path!

@@ -56,7 +56,7 @@ This is built on the Jupyter Notebook v6.5.6 and IPython 8.25.0 (more notes will
- scikit-learn: 1.2.1 -> 1.5.0
- statsmodels: 0.14.2 (new)
- terminado: 0.17.1 -> 0.18.0
- tornado: 6.2 -> 6.4
- tornado: 6.2 -> 6.4.1
Copy link
Member

Choose a reason for hiding this comment

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

😬

Comment on lines -9 to -10
NAR_BASE="kbase/narrbase"
NAR_BASE_VER="7.0"
Copy link
Member

Choose a reason for hiding this comment

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

Not anymore it doesn't!

@ialarmedalien ialarmedalien merged commit 59f5454 into develop Jun 11, 2024
6 of 10 checks passed
@ialarmedalien ialarmedalien deleted the random_updates branch June 11, 2024 12:23
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