Skip to content

pyrevit-hosts.json cached version update, branch source, preview release listing#3047

Merged
jmcouffin merged 5 commits intodevelopfrom
hosts-cached-version-update
Feb 1, 2026
Merged

pyrevit-hosts.json cached version update, branch source, preview release listing#3047
jmcouffin merged 5 commits intodevelopfrom
hosts-cached-version-update

Conversation

@jmcouffin
Copy link
Copy Markdown
Contributor

@jmcouffin jmcouffin commented Feb 1, 2026

Use develop for hosts file, fix env cache, and list Revit Preview Release

This PR does three things:

1. Hosts file from develop
The CLI now fetches pyrevit-hosts.json from the develop branch instead of TargetBranch (master), so host data stays up to date. A new constant HostsFileBranch = "develop" is used only for this URL; clones and other behavior still use TargetBranch. A unit test checks that HostFileURL contains "develop" and "pyrevit-hosts.json".

2. Env uses cache and refreshes when stale
pyrevit env was sometimes using the bundled hosts file from bin instead of the cache. The cache path getter in JSONDataSource now returns the configured cache path whenever it is set (not only when the directory exists), so the cache is always tried first. In addition, at the start of MakeEnvReport we call RevitProductData.RefreshIfStale() and PyRevitProductData.RefreshIfStale(), so hosts and products are re-downloaded only when the cached file is older than one day (or missing). That way env uses the latest data when possible without hitting the network every time.

3. List Revit Preview Release
Revit Preview Release (e.g. 2027) was not listed because the Uninstall registry filter required a four-digit year in the display name. A second regex was added to also match "Revit Preview Release" and "Autodesk Revit Preview Release" (case-insensitive). Entries that match either the existing pattern or this preview pattern are now processed, so the preview product appears under Installed Revits and can be used for attach/detach like other Revit versions.

Files changed:

Consts.cs, RevitProduct.cs, PyRevitProduct.cs, JSONDataSource.cs, PyRevitCLIAppCmds.cs, pyRevitLabs.UnitTests.pyRevit.cs

  • Changes are tested and verified to work as expected (unit test for HostFileURL; manual CLI: pyrevit update, pyrevit env, clone + attach to 2027 Preview Release).

Additional Notes

  • Hosts file: Download URL is https://raw.githubusercontent.com/pyrevitlabs/pyRevit/develop/bin/pyrevit-hosts.json. Cached at %AppData%\pyRevit\Cache\pyrevit-hosts.json.
  • Preview: Attach/detach and pyrevit env were verified with Revit 2027 Preview Release installed at C:\Program Files\Autodesk\Revit Preview Release.
  • Regression: Existing Revit entries (e.g. 2024–2026) and “Revit Content Libraries” exclusion are unchanged; only the new preview pattern was added.

…Data

- Added HostsFileBranch constant to Consts.cs for clarity on branch usage.
- Updated HostFileURL in RevitProduct.cs to reference HostsFileBranch instead of TargetBranch.
- Added unit test to verify that HostFileURL uses the develop branch for the hosts file.
- Added RefreshIfStale methods to PyRevitProduct and RevitProduct classes to allow for non-forced updates of product data.
- Updated MakeEnvReport method in PyRevitCLIAppCmds to call RefreshIfStale for both Revit and PyRevit product data, ensuring the environment report reflects the latest information.
- Improved data cache path verification in JSONDataSource to check for null or empty values.
- Added a new regex pattern to match "Revit Preview Release" and "Autodesk Revit Preview Release" in the RevitProduct class.
- Updated the app name matching logic to account for both standard and preview Revit versions.
@jmcouffin jmcouffin self-assigned this Feb 1, 2026
@jmcouffin jmcouffin added the Command Line Utility (CLI) Issues related to pyRevit CLI tool [subsystem] label Feb 1, 2026
@jmcouffin jmcouffin requested a review from Copilot February 1, 2026 12:27
@jmcouffin jmcouffin changed the title Hosts-cached-version-update pyrevit-hosts.json cached version update, branch source, preview release listing Feb 1, 2026
Copy link
Copy Markdown
Contributor

@devloai devloai bot left a comment

Choose a reason for hiding this comment

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

PR Summary:

This PR adds three improvements to pyRevit CLI:

  • Hosts file from develop branch: Downloads pyrevit-hosts.json from develop instead of master to ensure latest Revit version data
  • Cache refresh optimization: pyrevit env now uses cached data with staleness checking (refreshes only when > 1 day old) instead of always using bundled files or hitting the network
  • Revit Preview Release detection: Adds regex pattern to detect and list Revit Preview Release installations in registry for attach/detach operations

Review Summary:

The PR implements well-designed features with appropriate separation of concerns (using HostsFileBranch constant specifically for host data while keeping other operations on TargetBranch). The RefreshIfStale() methods cleanly implement cache staleness checking. The Revit Preview Release regex correctly matches both "Revit Preview Release" and "Autodesk Revit Preview Release" patterns.

1 medium-severity issue identified: The JSONDataSource.DataCachePath getter change removes directory existence checking, which could cause UpdateData() to fail silently if the cache directory is deleted after initialization. A simple fix is to add CommonUtils.EnsurePath() before downloading.

The unit test appropriately validates the HostFileURL uses the develop branch. Code follows C# conventions and includes proper XML documentation.

Follow-up suggestions:

  • @devloai fix the identified cache directory issue
  • @devloai add integration tests for cache refresh behavior

public string DataCachePath {
get {
if (CommonUtils.VerifyPath(_dataSourceCachePath))
if (_dataSourceCachePath != null && _dataSourceCachePath != string.Empty)
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.

Potential issue: Cache directory deletion after initialization

The change from CommonUtils.VerifyPath(_dataSourceCachePath) (checks if directory exists) to checking only if the string is not null/empty means DataCachePath will return a configured path even if the directory doesn't exist on disk.

Analysis:

  • The setter at line 51 calls CommonUtils.EnsurePath() during construction, so the directory is created initially ✓
  • However, if the cache directory is deleted after initialization (e.g., user cleanup, disk error), this getter will still return that path
  • UpdateData() at line 117 calls CommonUtils.DownloadFile(DataSourceURL, dataSourceCacheFile)
  • DownloadFile() doesn't create parent directories - it will throw DirectoryNotFoundException if the directory doesn't exist

Impact:

  • GetAllData() will gracefully fall back to DefaultDataFilePath if cache file doesn't exist (current behavior works)
  • But UpdateData() will fail with an exception when trying to download updates if the cache directory was deleted

Suggested fix: Add directory recreation in UpdateData() before downloading:

logger.Debug("Downloading to \"{0}\"", dataSourceCacheFile);
CommonUtils.EnsurePath(Path.GetDirectoryName(dataSourceCacheFile));
CommonUtils.DownloadFile(DataSourceURL, dataSourceCacheFile);

This makes UpdateData() resilient to cache directory deletion while keeping the intended behavior of always using the configured cache path.

Apply quick fix

actions

Quick Fix: Apply a small focused fix for this specific issue (takes < 1min).

Feedback: Rate this comment to help me improve future code reviews:

  • 👍 Good - Helpful and accurate
  • 👎 Poor - Wrong, unclear, or unhelpful
  • Skip if you don't have any strong opinions either way.

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.

Fixed in a5fdd6b - Added cache directory recreation before download to handle post-initialization deletion.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates pyRevit CLI to fetch host data from the develop branch, improves environment report caching behavior, and adds support for detecting Revit Preview Release installations.

Changes:

  • Hosts file now fetched from develop branch instead of master to ensure up-to-date host data
  • Environment command now uses cached data and only refreshes when stale (older than 1 day)
  • Revit Preview Release installations (e.g. 2027 preview) are now detected and can be used with attach/detach commands

Reviewed changes

Copilot reviewed 7 out of 82 changed files in this pull request and generated no comments.

Show a summary per file
File Description
dev/pyRevitLabs/pyRevitLabs.Common/Consts.cs Adds HostsFileBranch constant set to "develop" for fetching latest host data
dev/pyRevitLabs/pyRevitLabs.TargetApps.Revit/RevitProduct.cs Updates HostFileURL to use HostsFileBranch; adds previewFinder regex to detect Preview Release; adds RefreshIfStale method
dev/pyRevitLabs/pyRevitLabs.PyRevit/PyRevitProduct.cs Adds RefreshIfStale method for conditional data updates
dev/pyRevitLabs/pyRevitLabs.Common/JSONDataSource.cs Changes DataCachePath getter to return configured path even when directory doesn't exist yet, enabling cache-first behavior
dev/pyRevitLabs/pyRevitCLI/PyRevitCLIAppCmds.cs Calls RefreshIfStale for both Revit and pyRevit data before generating environment report
dev/pyRevitLabs/pyRevitLabs.UnitTests/pyRevitLabs.UnitTests.pyRevit.cs Adds unit test verifying HostFileURL points to develop branch and pyrevit-hosts.json
dev/pyRevitLabs/pyRevitCLIAutoComplete/pyrevit-autocomplete.go Alphabetizes flag definitions for consistency (cosmetic)
bin/*.runtimeconfig.json Adds MetadataUpdater.IsSupported=false for .NET 8 runtime configuration
bin/**/*.dll Updated compiled binaries reflecting source code changes

- Add CommonUtils.EnsurePath() call before DownloadFile() to recreate cache directory if deleted
- Makes UpdateData() resilient to cache directory deletion after initialization
@jmcouffin jmcouffin merged commit 115a552 into develop Feb 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1304-wip

@jmcouffin jmcouffin deleted the hosts-cached-version-update branch February 1, 2026 13:20
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1323-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1433-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1538-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1543-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1553-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1612-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1624-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1738-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1743-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1829-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1937-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 6.0.0.26032+1956-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 6.0.0.26032+2005-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 6.0.0.26032+2008-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New public release are available for 6.0.0.26032+2040

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New public release are available for 6.0.0.26032+2040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Command Line Utility (CLI) Issues related to pyRevit CLI tool [subsystem]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants