Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

## v0.11.0

* Support optional dataframe output from `get_runs`.

## v0.10.1

* The worker process now no longer gives a long delay when a run has finished (now at most ~1 second).
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
long_description_content_type="text/markdown",
url="https://simvue.io",
platforms=["any"],
install_requires=["dill", "requests", "msgpack", "tenacity", "pyjwt", "psutil", "pydantic", "plotly"],
install_requires=["dill", "requests", "msgpack", "tenacity", "pandas", "pyjwt", "psutil", "pydantic", "plotly"],
package_dir={'': '.'},
packages=["simvue"],
package_data={"": ["README.md"]},
Expand Down
2 changes: 1 addition & 1 deletion simvue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from simvue.client import Client
from simvue.handler import Handler
from simvue.models import RunInput
__version__ = '0.10.1'
__version__ = '0.11.0'
10 changes: 8 additions & 2 deletions simvue/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from .serialization import Deserializer
from .utilities import get_auth
from .converters import to_dataframe

CONCURRENT_DOWNLOADS = 10
DOWNLOAD_CHUNK_SIZE = 8192
Expand Down Expand Up @@ -57,7 +58,7 @@ def get_run(self, run, system=False, tags=False, metadata=False):
return None


def get_runs(self, filters, system=False, tags=False, metadata=False):
def get_runs(self, filters, system=False, tags=False, metadata=False, format='dict'):
"""
Get runs
"""
Expand All @@ -73,7 +74,12 @@ def get_runs(self, filters, system=False, tags=False, metadata=False):
return None

if response.status_code == 200:
return response.json()
if format == 'dict':
return response.json()
elif format == 'dataframe':
return to_dataframe(response.json())
else:
return None

return None

Expand Down
35 changes: 35 additions & 0 deletions simvue/converters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
def to_dataframe(data):
"""
Convert runs to dataframe
"""
import pandas as pd
columns = {}
for run in data:
for item in ('name', 'status', 'folder', 'created', 'started', 'ended'):
if item not in columns:
columns[item] = []
if item in run:
columns[item].append(run[item])
else:
columns[item].append()

if 'system' in run:
for section in run['system']:
if section in ('cpu', 'gpu', 'platform'):
for item in run['system'][section]:
if 'system.%s.%s' % (section, item) not in columns:
columns['system.%s.%s' % (section, item)] = []
columns['system.%s.%s' % (section, item)].append(run['system'][section][item])
else:
if 'system.%s' % section not in columns:
columns['system.%s' % section] = []
columns['system.%s' % section].append(run['system'][section])

if 'metadata' in run:
for item in run['metadata']:
if 'metadata.%s' % item not in columns:
columns['metadata.%s' % item] = []
columns['metadata.%s' % item].append(run['metadata'][item])

df = pd.DataFrame(data=columns)
return df