pyrevit-hosts.json cached version update, branch source, preview release listing#3047
pyrevit-hosts.json cached version update, branch source, preview release listing#3047
Conversation
…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.
There was a problem hiding this comment.
PR Summary:
This PR adds three improvements to pyRevit CLI:
- Hosts file from develop branch: Downloads
pyrevit-hosts.jsonfrom develop instead of master to ensure latest Revit version data - Cache refresh optimization:
pyrevit envnow 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) |
There was a problem hiding this comment.
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 callsCommonUtils.DownloadFile(DataSourceURL, dataSourceCacheFile)DownloadFile()doesn't create parent directories - it will throwDirectoryNotFoundExceptionif the directory doesn't exist
Impact:
GetAllData()will gracefully fall back toDefaultDataFilePathif 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.
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.
There was a problem hiding this comment.
Fixed in a5fdd6b - Added cache directory recreation before download to handle post-initialization deletion.
There was a problem hiding this comment.
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
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1304-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1323-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1433-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1538-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1543-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1553-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1612-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1624-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1738-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1743-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1829-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1937-wip |
|
📦 New work-in-progress (wip) builds are available for 6.0.0.26032+1956-wip |
|
📦 New work-in-progress (wip) builds are available for 6.0.0.26032+2005-wip |
|
📦 New work-in-progress (wip) builds are available for 6.0.0.26032+2008-wip |
|
📦 New public release are available for 6.0.0.26032+2040 |
|
📦 New public release are available for 6.0.0.26032+2040 |
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
envuses 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:
Additional Notes
https://raw.githubusercontent.com/pyrevitlabs/pyRevit/develop/bin/pyrevit-hosts.json. Cached at%AppData%\pyRevit\Cache\pyrevit-hosts.json.C:\Program Files\Autodesk\Revit Preview Release.