Skip to content

Get metrics working #522

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

Merged
merged 11 commits into from
Jun 19, 2025
Merged

Get metrics working #522

merged 11 commits into from
Jun 19, 2025

Conversation

brian-rose
Copy link
Member

@brian-rose brian-rose commented Jun 19, 2025

Closes #521

Seeing if including Jupyterlab in the environment file resolves the build-time failure of the metrics script.

This PR attempts to fix the broken metrics script. Two key changes:

  • include all the necessary packages for the python metrics script in the environment.yml
  • Modify the workflow calls to pass the necessary Google Analytics secrets to the build-book.yml workflow where myst build is called.

Limitation (discussed inline below): Can't pass the secrets for Pull Requests that originate from other forks. So metrics won't build in the previews. Including this preview.

Copy link
Contributor

github-actions bot commented Jun 19, 2025

👋 Thanks for opening this PR! The Cookbook will be automatically built with GitHub Actions. To see the status of your deployment, click below.
🔍 Git commit SHA: 9d7b102
✅ Deployment Preview URL: https://projectpythia.github.io/_preview/522

@brian-rose
Copy link
Member Author

brian-rose commented Jun 19, 2025

It would be useful to be notified of failures in the metrics script at build time. Related to ProjectPythia/cookbook-actions#150

Opened a separate issue for that: #523

@brian-rose
Copy link
Member Author

Now the environment seems to fully specified.

We have a new failure. The line

PRIVATE_KEY = os.environ.get('PRIVATE_KEY').replace('\\n', '\n')

generates

AttributeError: 'NoneType' object has no attribute 'replace'

indicating that the PRIVATE_KEY has not been set in the repo secrets.

This is probably still over at https://github.com/projectpythia-mystmd/projectpythia-mystmd.github.io

@brian-rose
Copy link
Member Author

The metrics script was developed along with this deploy.yml that explicitly sets PRIVATE_KEY and PRIVATE_KEY_ID in the run time environment.

We need to adapt the build workflow used here to do something similar.

@brian-rose
Copy link
Member Author

Workflows adapted to handle these two secrets: ProjectPythia/cookbook-actions#151

@brian-rose
Copy link
Member Author

brian-rose commented Jun 19, 2025

The limitation here is that the metrics build still won't work for pull requests, because the PR branch that triggers the build will not have access to the secrets.

I'm not sure how to get around that. That would definitely complicate #523 if all PR builds report failure because they can't run the metrics scripts.

@brian-rose
Copy link
Member Author

So I think the current status of this PR is that it will fix the broken metrics script for deployments that originate from the main repo (e.g. on merge of this PR, or on nightly builds).

But I can't test that without merging the PR.

@brian-rose brian-rose marked this pull request as ready for review June 19, 2025 14:45
@brian-rose brian-rose requested a review from a team as a code owner June 19, 2025 14:45
@brian-rose brian-rose requested review from dcamron and mgrover1 and removed request for a team June 19, 2025 14:45
@brian-rose brian-rose requested a review from jukent June 19, 2025 14:49
@brian-rose
Copy link
Member Author

I think this is all set now, but again, can't really tell if the metrics will work until after merging.

@brian-rose brian-rose merged commit 8645279 into ProjectPythia:main Jun 19, 2025
3 checks passed
@brian-rose brian-rose deleted the fix-metrics branch June 19, 2025 18:41
github-actions bot pushed a commit that referenced this pull request Jun 19, 2025
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.

Metrics are not working
1 participant