GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Python 3 Upgrade (minimal) by offbyone · Pull Request #577 · python/planet

Conversation

@offbyone

@offbyone offbyone commented Oct 7, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Note: This PR is built on the work started by @JacobCoffee in #569

A minimal Python 2 to 3 upgrade for planet. This is not a complete rewrite, it is the code changes necessary to allow the existing sequential feed updater to run using Python 3.12 rather than 2.... well, probably 2. Looking at this code I suspect it was Python 1, mostly.1

Notable Changes

  • replaced the templating system with jinja2
  • replaced the HTML santization library with markupsafe
  • unvendored feedparser
  • unvendored stdlib logging.
  • added a pyproject.toml
  • added at least a small "this thing sort of works" test
  • version 4.0

Notable Unchanges

  • the caching system is unchanged and still based on shelve
  • no parallelization has been added
  • only the least-invasive code changes necessary to generate the planet HTML were made

Work left to do

  • add more tests
  • add automation for the above tests
  • refactor to make caching more inspectable and debuggable
  • parallel feed downloading
  • Confirm that Database corruption with the shelve module cpython#91228 is only affecting this on macOS

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
JacobCoffee and others added 20 commits July 22, 2024 17:32
@JacobCoffee
feat: initial py2 to 3 work
9979bc6
@JacobCoffee
feat: upgrade sanitze,feedparser
bc58d1c
@JacobCoffee
style(optional): apply basic ruff linting and formatting
7d43518
@JacobCoffee
feat: pyupgrade against latest
46dfdf0
@JacobCoffee
style(optional): apply ruff against latest
d03851f
@JacobCoffee
style(optional): apply ruff against latest
a8484cf
@JacobCoffee
feat: upgrade docker config
7e5539e
@JacobCoffee
feat: working-ish app
d0a199e
@ewdurbin
push along
ada79c1
@ewdurbin
explicitly check for times when setting to CachedInfo
4be16d9
@offbyone
Drop the vendored dependencies
cddaff0
@offbyone
Move the top level project into the root
b023876
@offbyone
Convert the test templates to jinja2
44a8595
@offbyone
Make the test config use relative paths
a1b9e4e
@offbyone
Delete replaceable dependencies
29e2ea5
- removed the compat_logging, since logging is in the stdlib
- removed sanitize in favor of markupsafe
@offbyone
WIP: upgrade to 3 in truth
86e31f9
- starting to add typing
- fixed boolean flags in many places
- switch from hand-parsed args to argparse
- switch from htmltmpl to jinja2

TODO:

- core templates need to be converted to jinja2
- cache keys are still failing
@offbyone
Convert the main templates to jinja2
7419397
@offbyone
Correctly identify cache keys from the current item
4579636
The 2to3 conversion changed the `has_key` to `in` but in this instance,
the class overrides `__contains__` in a way that changes the semantics
of it.
@offbyone
Various small fixes for 2 to 3
1241a86
- use markupsafe instead of the stripHtml mini-class
- fix sorting of news items
- handle out of bound dates (terribly)
@offbyone
Merge remote-tracking branch 'upstream/master' into py2-to-3
aedc01f
@ewdurbin

ewdurbin commented Oct 8, 2024

Copy link
Copy Markdown
Member

Hi @offbyone! Thanks for picking up the torch here!

Is this in a state that generates usable output, or does it still have some ways to go before being (manually) testable?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@offbyone

offbyone commented Oct 8, 2024

Copy link
Copy Markdown
Contributor Author

It generates useful input on first run, I'm still having some issues with caching. I expect to have time to dig into that this week.

JacobCoffee reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mariatta

Mariatta commented Oct 8, 2024

Copy link
Copy Markdown
Member

Thank you @offbyone for the great work.
I'm not super well-versed with infra/devops kind of thing, but wondering if this is something we can like have deploy preview build kind of thing?

I'm also wishing we could automate the check for valid rss using GH actions or as part of CI. Would that be possible to add? Should I open an issue about it?

JacobCoffee reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@offbyone

offbyone commented Oct 9, 2024

Copy link
Copy Markdown
Contributor Author

Opening the issue can't hurt; worst-case, it won't happen, but if it makes sense to do, we can.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mariatta

Mariatta commented Oct 9, 2024

Copy link
Copy Markdown
Member

Thanks. I've opened #579 and #580

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

offbyone added 2 commits October 9, 2024 23:26
@offbyone
Actually add some minimal tests
0998580
@offbyone
Update the planet-cache.py admin utility
89f8fc5
- switch to argparse
- fix a couple of minor 2-3 bugs
- slightly nicer logging of a couple of exceptions
@offbyone
offbyone changed the base branch from py2-to-3 to master October 10, 2024 06:45
@offbyone

offbyone commented Oct 10, 2024

Copy link
Copy Markdown
Contributor Author

Okay, I'd call this ready to review.

I don't know much about how it's currently running or deployed, although I can make some inferences based on the current code. I'm happy to sysadmin that shit if the owners of the host want me to.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@offbyone
Work around a DB consistency bug on macOS
aa13325
Mitigates the impact of python/cpython#91228
ewdurbin added a commit to python/psf-salt that referenced this pull request Oct 10, 2024
@ewdurbin
planet: deploy planet from a py2 specific branch
3cac588
temporary measure while python/planet#577 is in progress
@ewdurbin ewdurbin mentioned this pull request Oct 10, 2024
Pin planet python/psf-salt#513
Merged
ewdurbin added a commit to python/psf-salt that referenced this pull request Oct 10, 2024
@ewdurbin
planet: deploy planet from a py2 specific branch
da7c535
temporary measure while python/planet#577 is in progress
@ewdurbin ewdurbin mentioned this pull request Oct 10, 2024
feat: python2 to 3 #569
Closed
ewdurbin added a commit to python/psf-salt that referenced this pull request Oct 10, 2024
@ewdurbin
Pin planet (#513)
6c29e01
planet: deploy planet from a py2 specific branch

temporary measure while python/planet#577 is in progress
@ewdurbin
ewdurbin changed the base branch from master to py3 October 10, 2024 12:35
@ewdurbin

ewdurbin commented Oct 10, 2024

Copy link
Copy Markdown
Member

Merging this into a new py3 branch to temporarily deploy it alongside the current deployment.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ewdurbin
ewdurbin merged commit daff861 into python:py3 Oct 10, 2024
@ewdurbin

ewdurbin commented Oct 10, 2024

Copy link
Copy Markdown
Member

https://planetpython.org/3/ is now running and updating along side the main instance.

The initial result is a little confusing, I guess we'll see how it behaves over time?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@offbyone

offbyone commented Oct 10, 2024

Copy link
Copy Markdown
Contributor Author

No, I think I see what's happening there.

There are two things that I'll want to address, one is full text feeds and the other is something that's possibly stateful. The DB has a field - hidden -- that it seems to infer from something about how "new" the feed is. Since I don't have the original DB, it's possible there are feeds not showing up in the new one that might otherwise be there. If you can get me the contents of /srv/planetpython.org/ and /srv/cache from the old runner, I can see about getting things consistent.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@offbyone

offbyone commented Oct 10, 2024

Copy link
Copy Markdown
Contributor Author

Oh, man... yeah, there are some bugs in that output now that I can see it beside the current planet. I'll put together some fixes by the weekend (evenings are a bit slammed for me this week)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ewdurbin

ewdurbin commented Oct 10, 2024

Copy link
Copy Markdown
Member

Archives of current state:

https://planetpython.org/cache-1728569965.tgz
https://planetpython.org/planetpython.org-1728569990.tgz

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@offbyone

offbyone commented Oct 10, 2024

Copy link
Copy Markdown
Contributor Author

Can you tell me which version of python (and, possibly, OS version and dbm library version) are involved in generating that? I hope it won't matter, but I might need to spin up a replica of the original to use those caches.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JacobCoffee

JacobCoffee commented Oct 10, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@offbyone
Python3 is 3.12.2
Ubuntu 18.04.6 (behind due to Python2 impl)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ewdurbin

ewdurbin commented Oct 10, 2024

Copy link
Copy Markdown
Member
ee@planet:~$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.6 LTS"
ee@planet:~$ uname -a
Linux planet 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
ee@planet:~$ python
Python 2.7.17 (default, Mar  8 2023, 18:40:28) 
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
JacobCoffee reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ewdurbin

ewdurbin commented Oct 10, 2024

Copy link
Copy Markdown
Member

@offbyone 3.12.2

That's the preview deploy, the state is from the original.

JacobCoffee reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ewdurbin

ewdurbin commented Oct 10, 2024

Copy link
Copy Markdown
Member

Ah, @offbyone do you want the cache/output for the new version or the original?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@offbyone

offbyone commented Oct 10, 2024

Copy link
Copy Markdown
Contributor Author

Honestly, "both is good" is even better. That way I can apples-to-apples it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ewdurbin

ewdurbin commented Oct 10, 2024

Copy link
Copy Markdown
Member

for the new thing: https://planetpython.org/cache3-1728570557.tgz

$ python3.12 
Python 3.12.2 (main, Oct 10 2024, 13:10:02) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@offbyone

offbyone commented Oct 10, 2024

Copy link
Copy Markdown
Contributor Author

Okay, so I have some good news and some bad news.

The good news is that I can definitely get the ordering issues sorted.

The bad news is that as far as I can tell, I can't use the cache from the v2 version with v3, to retain the "hidden" state from the old feed cache. I'm looking into seeing how I can get that status, because it would radically change the feed if we lose it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@offbyone

offbyone commented Oct 10, 2024

Copy link
Copy Markdown
Contributor Author

I'm going to see if I can figure that one out somehow. I suspect I'm missing something with the weird ways dbm loads files.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@berrange berrange mentioned this pull request Oct 24, 2024
The preview of the new Python 3 port has broken HTML escaping in the XML feeds #582
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@offbyone @ewdurbin @Mariatta @JacobCoffee
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.