-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated version checking * Removed duplicated code
- Loading branch information
Showing
4 changed files
with
38 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
import os | ||
from datetime import datetime | ||
from photonai.base import PhotonRegistry | ||
from photonai.photonlogger import logger | ||
from photonai_graph.version import __version__ | ||
|
||
current_path = os.path.dirname(os.path.abspath(__file__)) | ||
registered_file = os.path.join(current_path, "registered") | ||
logger.info("Checking Graph Module Registration") | ||
if not os.path.isfile(registered_file): # pragma: no cover | ||
logger.info("Registering Graph Module") | ||
from photonai.base import PhotonRegistry | ||
|
||
from .version import __version__ | ||
|
||
|
||
def do_register(current_path, registered_file): | ||
reg = PhotonRegistry() | ||
reg.add_module(os.path.join(current_path, "photonai_graph.json")) | ||
with open(os.path.join(registered_file), "w") as f: | ||
f.write(str(datetime.now())) | ||
f.write(str(__version__)) | ||
|
||
|
||
def register(): | ||
current_path = os.path.dirname(os.path.abspath(__file__)) | ||
registered_file = os.path.join(current_path, "registered") | ||
logger.info("Checking PHOTONAI Graph Module Registration") | ||
if not os.path.isfile(registered_file): # pragma: no cover | ||
logger.info("Registering Graph Module") | ||
do_register(current_path=current_path, registered_file=registered_file) | ||
else: | ||
with open(os.path.join(registered_file), "r") as f: | ||
if f.read() == __version__: | ||
logger.info("Current version already registered") | ||
else: | ||
logger.info("Updating Graph Module") | ||
do_register(current_path=current_path, registered_file=registered_file) | ||
|
||
|
||
register() |