forked from singnet/das-poc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logger and made multiple fixes
- Loading branch information
Andre Senna
committed
Oct 14, 2022
1 parent
b7483e5
commit 583661d
Showing
8 changed files
with
115 additions
and
63 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import logging | ||
|
||
LOG_FILE_NAME = '/tmp/das.log' | ||
LOGGING_LEVEL = logging.INFO | ||
|
||
class Logger: | ||
__instance = None | ||
|
||
@staticmethod | ||
def get_instance(): | ||
if Logger.__instance is None: | ||
return Logger() | ||
return Logger.__instance | ||
|
||
def __init__(self): | ||
if Logger.__instance is not None: | ||
raise Exception("Invalid re-instantiation of Logger") | ||
else: | ||
print(f"Log initialized. Log file: {LOG_FILE_NAME}") | ||
logging.basicConfig( | ||
filename=LOG_FILE_NAME, | ||
level=LOGGING_LEVEL, | ||
format='%(asctime)s %(levelname)-8s %(message)s', | ||
datefmt='%Y-%m-%d %H:%M:%S') | ||
Logger.__instance = self | ||
|
||
def _prefix(self): | ||
return f"" | ||
|
||
def debug(self, msg): | ||
logging.debug(self._prefix() + msg) | ||
|
||
def info(self, msg): | ||
logging.info(self._prefix() + msg) | ||
|
||
def warning(self, msg): | ||
logging.warning(self._prefix() + msg) | ||
|
||
def error(self, msg): | ||
logging.error(self._prefix() + msg) | ||
|
||
def logger(): | ||
return Logger.get_instance() | ||
|
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,7 +1,19 @@ | ||
import argparse | ||
from das.distributed_atom_space import DistributedAtomSpace | ||
|
||
das = DistributedAtomSpace(knowledge_base_dir_name="/tmp/bio") | ||
#das = DistributedAtomSpace(knowledge_base_file_name="/tmp/bio/COVID-19-biogrid_LATEST.tab3.zip_2020-10-20.scm") | ||
#das = DistributedAtomSpace(knowledge_base_dir_name="./data/samples",show_progress=True) | ||
#das = DistributedAtomSpace(knowledge_base_file_name="./data/samples/animals.metta") | ||
def run(): | ||
parser = argparse.ArgumentParser( | ||
"Load MeTTa data into DAS", formatter_class=argparse.ArgumentDefaultsHelpFormatter | ||
) | ||
|
||
parser.add_argument('--knowledge-base', type=str, help='Path to a file or directory with a MeTTA knowledge base') | ||
|
||
args = parser.parse_args() | ||
|
||
das = DistributedAtomSpace() | ||
|
||
if args.knowledge_base: | ||
das.load_knowledge_base(args.knowledge_base) | ||
|
||
if __name__ == "__main__": | ||
run() |