Skip to content

Commit

Permalink
Small Python fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpn committed Jan 19, 2021
1 parent 57272fa commit 7bc8587
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
23 changes: 14 additions & 9 deletions python/perfecthash/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1932,35 +1932,35 @@ def get_yyyy_mm_dd_subdirs(dirname):

def get_csv_files(directory):
import glob
return [
return set(
f for f in glob.iglob(
f'{directory}/**/PerfectHashBulkCreate*.csv',
recursive=True
)
]
)

def get_all_bulk_create_parquet_files(directory):
import glob
return [
return set(
f for f in glob.iglob(
f'{directory}/**/PerfectHashBulkCreate*.parquet',
recursive=True
) if 'failed' not in f
] + [
).union(set(
f for f in glob.iglob(
f'{directory}/PerfectHashBulkCreate*.parquet',
recursive=False
) if 'failed' not in f
]
))

def get_best_bulk_create_parquet_files(directory):
import glob
return [
return set(
f for f in glob.iglob(
f'{directory}/**/PerfectHashBulkCreateBest*.parquet',
recursive=True
) if 'failed' not in f
]
)

def convert_csv_to_parquet(path, base_research_dir, out=None):
if not out:
Expand Down Expand Up @@ -2343,8 +2343,9 @@ def process_xperf_perfecthash_csv(path, out=None):
'ProcessID',
'ThreadID',
'CPU',
'ActivityId',
'BytesRequested',
'Success',
'Result',
]]

df.to_csv(path)
Expand All @@ -2355,6 +2356,7 @@ def process_xperf_perfecthash_csv(path, out=None):
#===============================================================================

def get_cache_line_coverage(df):
import numpy as np
count = df.NewBestGraphCount.values[0]
keys = [
f'BestGraph{i}_CountOfCacheLinesWithNumberOfAssigned_{n}'
Expand All @@ -2368,8 +2370,11 @@ def get_cache_line_coverage(df):
return (keys, values, attempts, columns)

def ridgeline_plot(df):
import joypy
import pandas as pd
import matplotlib.pyplot as plt
plt.ioff()
from matplotlib import cm
#plt.ioff()
keys_name = df.KeysName.values[0]
hash_func = df.HashFunction.values[0]
best_coverage_type = df.BestCoverageType.values[0]
Expand Down
5 changes: 3 additions & 2 deletions python/perfecthash/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,9 @@ class PathArg(PathInvariant):

def run(self):

from os.path import basename
from .analysis import convert_csv_to_parquet
convert_csv_to_parquet(self._path, self._out)
convert_csv_to_parquet(self._path, basename(self._path))

class ConvertAllCsvToParquet(InvariantAwareCommand):
"""
Expand All @@ -526,7 +527,7 @@ def run(self):

if path:
from os.path import basename
path = basename(path)
base = basename(path)
else:
path = base

Expand Down

0 comments on commit 7bc8587

Please sign in to comment.