Skip to content
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

[Bug]: get_config does not load latest from file #2409

Open
5 tasks done
onomou opened this issue Oct 3, 2024 · 0 comments
Open
5 tasks done

[Bug]: get_config does not load latest from file #2409

onomou opened this issue Oct 3, 2024 · 0 comments
Labels
Bug Bug that stops user from using the tool or a major portion of pyRevit functionality [class]

Comments

@onomou
Copy link
Contributor

onomou commented Oct 3, 2024

✈ Pre-Flight checks

  • I don't have SentinelOne antivirus installed (see above for the solution)
  • I have searched in the issues (open and closed) but couldn't find a similar issue
  • I have searched in the pyRevit Forum for similar issues
  • I already followed the installation troubleshooting guide thoroughly
  • I am using the latest pyRevit Version

🐞 Describe the bug

If get_config has already been called, and then the pyRevit_config.ini file is edited, get_config does not return the latest value from the file. This is true until the engine is reloaded (such as Ctrl + Shift + Alt.

⌨ Error/Debug Message

No error message. The old value is still returned from `get_config`.

♻️ To Reproduce

You can run this in pyRevit or RevitPythonShell.

from pyrevit import script
config = script.get_config('Demo Section')
config.first_var = 42
print('original value:', config.first_var)
script.save_config()

# edit pyRevit_config.ini ## Demo Section
# change first_var to something else
import configparser
cp = configparser.ConfigParser()
import os
config_file = os.path.join(os.getenv('APPDATA'), 'pyRevit', 'pyRevit_config.ini')
cp.read(config_file)
cp['Demo Section']['first_var'] = '12'
with open(config_file, 'w') as file:
    cp.write(file)

# this does not work
config = script.get_config('Demo Section')
print('still old value:', config.first_var) # prints 42

import sys
#del script.user_config
del sys.modules['pyrevit.userconfig']
config = script.get_config('Demo Section')
print('edited value:', config.first_var) # prints new value

⏲️ Expected behavior

The latest data from pyRevit_config.ini will be read and returned.

🖥️ Hardware and Software Setup (please complete the following information)

==> Registered Clones (full git repos)
==> Registered Clones (deployed from archive/image)
master | Deploy: "basepublic" | Branch: "master" | Version: "4.8.16.24121+2117" | Path: "C:\Users\<redacted>\AppData\Roaming\pyRevit-Master"
==> Attachments
master | Product: "23.1.4" | Engine: IPY340PR (340) | Path: "C:\Users\<redacted>\AppData\Roaming\pyRevit-Master" 
master | Product: "2022.1.5" | Engine: IPY340PR (340) | Path: "C:\Users\<redacted>\AppData\Roaming\pyRevit-Master" 
master | Product: "2021.1.9" | Engine: IPY340PR (340) | Path: "C:\Users\<redacted>\AppData\Roaming\pyRevit-Master" 
==> Installed Extensions
==> Default Extension Search Path
C:\Users\<redacted>\AppData\Roaming\pyRevit\Extensions
==> Extension Search Paths
==> Extension Sources - Default
https:/pyrevitlabs/pyRevit/raw/master/extensions/extensions.json
==> Extension Sources - Additional
==> Installed Revits
23.1.4 | Version: 23.1.40.56 | Build: 20240411_0945(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2023\"
2022.1.5 | Version: 22.1.50.17 | Build: 20230915_1530(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2022\"
2021.1.9 | Version: 21.1.90.15 | Build: 20230907_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2021\"
==> Running Revit Instances
PID: 51916 | 23.1.4 | Version: 23.1.40.56 | Build: 20240411_0945(x64) | Language: 0 | Path: "C:\Program Files\Autodesk\Revit 2023"
==> User Environment
Microsoft Windows 10 [Version 10.0.22631]
Executing User: <redacted>\<redacted>
Active User: <redacted>\<redacted>
Admin Access: No
%APPDATA%: "C:\Users\<redacted>\AppData\Roaming"
Latest Installed .Net Framework: 4.8
Installed .Net Target Packs: v4.0 v4.5 v4.5.1 v4.5.2 v4.6 v4.6.1 v4.7 v4.7.1 v4.7.2 v4.8 v4.X 
Installed .Net-Core Target Packs: v8.0.400 
pyRevit CLI v4.8.16.24121+2117.23a0b8cbc4babdeb29a0611e159d017bbe9cbad5

Additional context

A workaround is presented in the To Reproduce section. I posted about it here: Reload required on script update?

@onomou onomou added the Bug Bug that stops user from using the tool or a major portion of pyRevit functionality [class] label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug that stops user from using the tool or a major portion of pyRevit functionality [class]
Projects
None yet
Development

No branches or pull requests

1 participant