Skip to content

Fake dataset generation #103

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pipit/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import numpy as np
import pandas as pd
from ast import literal_eval
from io import StringIO


class Trace:
Expand Down Expand Up @@ -60,6 +62,10 @@ def from_nsight(filename):

@staticmethod
def from_csv(filename):
# detect if the input is a CSV as a string
if "," in filename:
# wrapping with StringIO allows pandas to read it
filename = StringIO(filename)
events_dataframe = pd.read_csv(filename, skipinitialspace=True)

# if timestamps are in seconds, convert them to nanoseconds
Expand All @@ -72,6 +78,14 @@ def from_csv(filename):
# ensure that ranks are ints
events_dataframe = events_dataframe.astype({"Process": "int32"})

# this next part is needed for fake test reading
# ensure that the attributes are a dict, not a string
if "Attributes" in events_dataframe.columns:
# use literal_eval so we're not running a security risk
events_dataframe["Attributes"] = events_dataframe["Attributes"].apply(
literal_eval
)

# make certain columns categorical
events_dataframe = events_dataframe.astype(
{
Expand Down
Loading