-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drain compatibility with Python 3.7 (#18)
* Add notebooks files to .gitignore + * Fix Drain compatibility with Python 3.7
- Loading branch information
1 parent
173db48
commit 85b60bd
Showing
4 changed files
with
28 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,5 @@ target/ | |
Unused/ | ||
.idea/ | ||
POP/ | ||
.ipynb_checkpoints/ | ||
*.ipynb |
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,21 +1,21 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
sys.path.append('../') | ||
from logparser import Drain | ||
|
||
input_dir = '../logs/HDFS/' # The input directory of log file | ||
output_dir = 'Drain_result/' # The output directory of parsing results | ||
log_file = 'HDFS_2k.log' # The input log file name | ||
log_format = '<Date> <Time> <Pid> <Level> <Component>: <Content>' # HDFS log format | ||
# Regular expression list for optional preprocessing (default: []) | ||
regex = [ | ||
r'blk_(|-)[0-9]+' , # block id | ||
r'(/|)([0-9]+\.){3}[0-9]+(:[0-9]+|)(:|)', # IP | ||
r'(?<=[^A-Za-z0-9])(\-?\+?\d+)(?=[^A-Za-z0-9])|[0-9]+$', # Numbers | ||
] | ||
st = 0.5 # Similarity threshold | ||
depth = 4 # Depth of all leaf nodes | ||
|
||
parser = Drain.LogParser(log_format, indir=input_dir, outdir=output_dir, depth=depth, st=st, rex=regex) | ||
parser.parse(log_file) | ||
#!/usr/bin/env python | ||
import sys | ||
sys.path.append('../') | ||
from logparser import Drain | ||
|
||
input_dir = '../logs/HDFS/' # The input directory of log file | ||
output_dir = 'Drain_result/' # The output directory of parsing results | ||
log_file = 'HDFS_2k.log' # The input log file name | ||
log_format = '<Date> <Time> <Pid> <Level> <Component>: <Content>' # HDFS log format | ||
# Regular expression list for optional preprocessing (default: []) | ||
regex = [ | ||
r'blk_(|-)[0-9]+' , # block id | ||
r'(/|)([0-9]+\.){3}[0-9]+(:[0-9]+|)(:|)', # IP | ||
r'(?<=[^A-Za-z0-9])(\-?\+?\d+)(?=[^A-Za-z0-9])|[0-9]+$', # Numbers | ||
] | ||
st = 0.5 # Similarity threshold | ||
depth = 4 # Depth of all leaf nodes | ||
|
||
parser = Drain.LogParser(log_format, indir=input_dir, outdir=output_dir, depth=depth, st=st, rex=regex) | ||
parser.parse(log_file) | ||
|
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 +1 @@ | ||
from Drain import * | ||
from .Drain import * |
85b60bd
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.
error: ('bad escape \s at position 0', 'occurred at index 0') issue with Python 3.7.
Do you have any fix for this problem?
85b60bd
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.
@AshimaChawla there are 2 options:
85b60bd
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.
Thanks@AnkitNassa. The code worked fine with 3.7 after changing
import regex as re and
splitter = re.sub(' +', '\\s+', splitters[k]) [Line no 326]