-
Notifications
You must be signed in to change notification settings - Fork 3
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
Ticket2624 file tracking #139
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the following exception, using latest build of genie_python installed from \\isis\inst$\Kits$\CompGroup\ICP\genie_python
. Do you perhaps have a different version of Python installed on your system (or, more precisely, GitPython version)? The git python version on the latest build on the build server is 0.3.6
...
INFO: Stopping IOC INHIBITR_01
Alarm server will update in 20 seconds from now
INFO: Stopping IOC CHIPIR_XYZ
Alarm server will update in 20 seconds from now
INFO: Stopping IOC GALIL_02
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Instrument\Apps\Python\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "C:\Instrument\Apps\Python\lib\threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "C:\Instrument\Apps\EPICS\ISIS\inst_servers\master\ConfigVersionControl\git_version_control.py", line 152, in _commit_and_push
self._commit()
File "C:\Instrument\Apps\EPICS\ISIS\inst_servers\master\ConfigVersionControl\git_version_control.py", line 141, in _commit
raise CommitToVersionControlException("Couldn't commit to version control")
CommitToVersionControlException: Couldn't commit to version control
Alarm server will update in 20 seconds from now
INFO: Stopping IOC SDTEST_01
Alarm server will update in 20 seconds from now
INFO: Stopping IOC TEST_01
Alarm server will update in 20 seconds from now
...
Code looks good, some small stylistic changes suggested in the review comments, but haven't been able to run this to test it properly.
time.sleep(RETRY_INTERVAL) | ||
|
||
raise Exception( | ||
"Could not save to device screens file at %s. Please check the file is not in use by another process." % file_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our standard (from the python style gui chat) is now to use .format()
rather than %
to format strings
Comment repeats as necessary
attempts += 1 | ||
time.sleep(RETRY_INTERVAL) | ||
|
||
raise Exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't raise Exception
, raise a specific exception instead.
BlockServer/fileIO/file_manager.py
Outdated
attempts += 1 | ||
time.sleep(RETRY_INTERVAL) | ||
|
||
raise Exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't raise Exception
BlockServer/fileIO/file_manager.py
Outdated
attempts += 1 | ||
time.sleep(RETRY_INTERVAL) | ||
|
||
raise Exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't raise Exception
BlockServer/fileIO/file_manager.py
Outdated
attempts += 1 | ||
time.sleep(RETRY_INTERVAL) | ||
|
||
raise Exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See if you can factor out this block - I've seen a very similar block 4 times so far. You might need to pass in a function to deal with the different bits but the basic
while attempts < RETRY_MAX_ATTEMPTS:
try:
with open(file_path, mode) as f:
# do something clever
except IOError:
attempts += 1
time.sleep(RETRY_INTERVAL)
#raise something clever
structure should be encapsulated somewhere
block_server.py
Outdated
# Start file watcher | ||
self._filewatcher = ConfigFileWatcherManager(SCHEMA_DIR, self._config_list, self._syn, self._devices) | ||
# self._other_files = UnclassifiedFileManager(self) TODO | ||
# self.on_the_fly_handlers.append(self._other_files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented code or complete TODO item.
return | ||
except Exception as err: | ||
except Exception: | ||
sleep(RETRY_INTERVAL) | ||
|
||
attempts += 1 | ||
|
||
raise CommitToVersionControlException("Couldn't commit to version control") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this exception never gets caught.
push_interval = PUSH_BASE_INTERVAL | ||
first_failure = True | ||
|
||
except GitCommandError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to catch CommitToVersionControlException
.
@@ -15,19 +15,18 @@ | |||
# http://opensource.org/licenses/eclipse-1.0.php | |||
|
|||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import appears to be unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not, I'm using os.path
in a few places here. Not sure why it gets highlighted, I have seen a few people asking the same question online but have not come across a satisfying answer so far
push_interval = PUSH_RETRY_INTERVAL | ||
if first_failure: | ||
print_and_log("Unable to push config changes, will retry in %i seconds" | ||
% PUSH_RETRY_INTERVAL, "MINOR") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use .format()
to format strings
Code looks good, functionally works. |
Description of work
Simplified the system responsible for keeping user scripts and configurations under version control:
VC is now managed by a thread running in the blockserver, which simply adds, commits and pushes all files in the repositories every 5 minutes. This change greatly reduces the complexity of the system, removes the need for any filewatchers, and with it previously problematic interactions between the filewatcher and the version control threads.
To test
ISISComputingGroup/IBEX#2624
Acceptance criteria
PUSH_BASE_INTERVAL
variable ingit_version_control.py
if it makes testing easierCode Review
Functional Tests
Final steps