Migrate Utility functions to core#2406
Conversation
|
@Ishaan-Chandak I just created a PR from your branch as it makes it easier to comment on the code. |
egede
left a comment
There was a problem hiding this comment.
Try to implement the changes suggested here. If that then removes the warnings, then the entire code base should be changed to use the new import location.
It would be good to write test cases for all the different utility functions as well. If you decide to do this, the tests should utilise the mock system to avoid actually submitting and running any jobs as part of the tests.
|
Another comment is that we should make sure that the old import location still works but emits a deprecation warning. While the code is not formally part of the Ganga API, it will have a number of external users. |
| import GangaCore.Core | ||
| from GangaCore.Core.GangaRepository import getRegistry | ||
| from GangaCore.Core.InternalServices.ShutdownManager import _protected_ganga_exitfuncs | ||
| from ganga.GangaCore.Utility.Config.Config import ConfigError |
There was a problem hiding this comment.
Is ConfigError ever used? If not, we can delete this line.
There was a problem hiding this comment.
no it was not being used,
I have deleted this
|
OK, so I guess the final thing that is required is to change all the imports in the testing code. I give a list below. I think a global search and replace with the new location should work. |
| warnings.warn( | ||
| "The module 'ganga.GangaTest.Framework.util' is deprecated and will be removed in a future release. " | ||
| "Please use 'ganga.GangaCore.Utility.job_monitoring' instead.", | ||
| DeprecationWarning, | ||
| stacklevel=2 | ||
| ) |
There was a problem hiding this comment.
Did you check that this is actually working
There was a problem hiding this comment.
Yes, I did test this. I tested the read_file functionality. I created a python script and a dummy read file and checked by importing the read_file function from GangaTest.framework.utils.
It did work correctly.
| import unittest | ||
| failureException = unittest.TestCase.failureException | ||
|
|
||
| try: | ||
| from GangaCore.Utility.Config import getConfig | ||
| config = getConfig('TestingFramework') | ||
| except BaseException: # if we are outside Ganga, use a simple dict | ||
| config = {} No newline at end of file |
There was a problem hiding this comment.
This is not the right way to solve the problem of the failing tests. The code in GangaCore should not depend on unittest and should not mention TestingFramework. So the required change has to be made in the failing tests instead.
|
OK, so I think I can see two issues here with TestVirtualizationDocker.py
|
|
As suggested, I have moved the test to the mentioned location and also changed the import for sleep_until_completed. |
|
Wow, the latest round of testing shows that we have seriously managed to break something here. Quite likely it is all related to the missing |
|
The error in the testing is now regarding X.509 certificate expiry. Like in this workflow we can see that the expiry is due in 8 days. Can replacing the certificate solve this issue ? |
I solved this problem and will restart the tests now. I do not think that is the full issue though. |
|
Yup, This error is similar ro the one that we faced earlier. |
|
OK, looked at this a bit closer. We in fact do need the |
|
I feel the if statement present before was neccessary to prevent the errors that are appearing now, |
No description provided.