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

Prevent save config to home in tests #2016

Merged

Conversation

GateBuilder
Copy link
Contributor

@GateBuilder GateBuilder commented May 20, 2020

This PR removes redundant and unnecessary execution of save_to_home function in tests.
The functionality of the corresponding context managers are not effected and they do not need this command. Although I tested their functionality without this attribute, please confirm that this is indeed the case.

@jenshnielsen

@jenshnielsen
Copy link
Collaborator

@GateBuilder I suspect but I am not sure that these context managers does this because there is a bunch of places in the code where a new config is generated by calling Config() these really should read the config from the default qcodes.config instead. We may need to change those. The way to check I think is to see if the location and work_station not set warning is triggered when running the tests after all the tests passes

@jenshnielsen
Copy link
Collaborator

For refererence the config instance creation below all look suspicious

qcodes\tests\test_config.py
177:        qcodes.config = Config()
224:        self.conf = Config()
322:        cfg = Config()
341:    cfg = Config()
363:        cfg = Config()

qcodes\tests\dataset\test_guids.py
24:    ocfg: DotDict = Config().current_config
30:        cfg = Config()
41:        cfg = Config()
66:    orig_cfg = Config().current_config
73:        cfg = Config().current_config
86:    orig_cfg = Config().current_config
93:        cfg = Config().current_config
129:        cfg = Config()

qcodes\tests\dataset\test_database_creation_and_upgrading.py
51:    cfg = Config()

qcodes\tests\dataset\test_database_extract_runs.py
514:    cfg = Config()

qcodes\dataset\sqlite\queries.py
1596:    cfg = Config()

qcodes\dataset\guids.py
28:    cfg = Config()
84:    cfg = Config()
109:    cfg = Config()

@jenshnielsen
Copy link
Collaborator

jenshnielsen commented May 20, 2020

These calls to save_to_home could also be problematic if they are called by tests

qcodes\dataset\guids.py
102:    cfg.save_to_home()
128:    cfg.save_to_home()

We may need to make sure that we set the home dir to a isolated temp dir before any of these are called in a test

@GateBuilder
Copy link
Contributor Author

@jenshnielsen I tested the one of the context managers without save_to_home where I first change my location and work_station numbers. They returned back the original state in the config file at my home directory without a problem.

@jenshnielsen
Copy link
Collaborator

@GateBuilder great lets hope that is the case for all of them :)

@GateBuilder
Copy link
Contributor Author

@jenshnielsen Ok I understand what you mean, indeed why don't we use the default config?. Let me change this PR to a draft; rather tricky stuff here I do not wanna rush.

@GateBuilder GateBuilder marked this pull request as draft May 20, 2020 14:32
@GateBuilder
Copy link
Contributor Author

GateBuilder commented Jun 4, 2020

I have made some changes in separate tests and files. The followings are the remaining problems?

  • I cannot get rid off two Config() calls. Both resides in test_config.py. First one is in line 177. Removing this one while does not effect the test itself, causes failure of the test test_subscribing.py which uses the context manager created in the former. Second one is in line 224. Removing this call or replacing it with in memory config results in multiple failures. I could not figure out a way.

  • Good news is with these changes now xdist works for 2 cores. For higher core numbers for example 4, I got 2 failures relating to logging. Hopefully can be solved.

Overall, this is a fine improvement. Please let me know if you have any suggestions concerning getting rid off remaining Config() calls.

@jenshnielsen @astafan8 @lakhotiaharshit

@GateBuilder GateBuilder marked this pull request as ready for review June 4, 2020 14:29
@jenshnielsen
Copy link
Collaborator

I think we should land this as is if passing and then revisit the remaining ones

previous version would overwrite the config class with the dict internal to the config class :(
@codecov
Copy link

codecov bot commented Jun 8, 2020

Codecov Report

Merging #2016 into master will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2016   +/-   ##
=======================================
  Coverage   71.31%   71.31%           
=======================================
  Files         149      149           
  Lines       19866    19866           
=======================================
  Hits        14167    14167           
  Misses       5699     5699           

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.

3 participants