Skip to content

support redirecting for older versions of phoebe - #7

Open
kecnry wants to merge 2 commits into
phoebe-project:masterfrom
kecnry:version-redirect
Open

support redirecting for older versions of phoebe#7
kecnry wants to merge 2 commits into
phoebe-project:masterfrom
kecnry:version-redirect

Conversation

@kecnry

@kecnry kecnry commented Jun 23, 2026

Copy link
Copy Markdown
Member

This implements in-flask redirecting to the appropriate subdomain/container running the same server code but a different version of phoebe. It does so by:

  • having smarter logic to map "?phoebe_version=latest" to the actual latest version, by looking at pypi, with the cache being reset with passbands every hour
  • every request that uses ?phoebe_version will run through _unpack_version_request and compares the version > subdomain mapping (in tables_subdomain) between the requested-version of PHOEBE with the version running on this instance of the server. If they are different, flask will redirect to the subdomain mapped from the requested-version of PHOEBE (which will then run the same logic and see that it is a match, and continue to process the request).

tables.phoebe-project.org remains the publicly accessible endpoint used by the website and PHOEBE code (and will going forward). As new versions of PHOEBE motivate new subdomains/containers, we should update the logic in tables_subdomain to create a new subdomain for what was previously covered by the default and deploy to all running instances.

@kecnry
kecnry requested a review from aprsa June 23, 2026 17:32

@aprsa aprsa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's merge the two PRs and revisit? Overall this looks good to me but I would love to avoid globals...

Comment thread server.py
CORS(app)
app._verbose = True

class VersionRedirect(Exception):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

has this been tested?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

no, I guess we could test with a different case locally, or test once this is in place and replace with redirect returns if necessary (that just makes the code a little muddier and more repetitive)

Comment thread server.py
phoebe.interactive_off()

def _get_phoebe_version_latest():
global _phoebe_version_latest_cache

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we really save on performance by caching this? If so, then perhaps we should offload caching to apache, much like what we do for passband files now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

well I think we definitely don't want to reach out to pypi on every request, so some sort of internal caching is necessary

Comment thread server.py

def _pbs_flush(force=False):
global _pbs_last_flush
global _pbs_last_flush, _phoebe_version_latest_cache

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

worth noting here that this will flush the internal list but the original list will still be cached by apache for up to 1 hour. See ground_truth branch README for details.

Comment thread server.py
def _pbs_flush(force=False):
global _pbs_last_flush
global _pbs_last_flush, _phoebe_version_latest_cache
if _pbs_last_flush is None or force or (datetime.now()-_pbs_last_flush).total_seconds() > (60*60):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't 1 hour a bit excessive to check for the new passband version? Perhaps 1 day or even 1 week or even 1 month, with the ability to force it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

perhaps, but I don't want to add to another thing we have to remember to do at release. We might be able to make a call to the force within the release action itself, in which case we could just have it fetched at startup and when manually refreshed 🤔

Comment thread server.py
"""

if version.parse(phoebe_version) < version.parse('2.5'):
return 'tables-20-24.phoebe-project.org'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd do tables24.phoebe-project.org here

Comment thread server.py

return phoebe_version_request

def _generate_request_passband(pbr, content_request, export_inorm_tables=False, gzipped=False, save=True):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this requires merging with the other PR

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