Skip to content

Commit

Permalink
More on docs and minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
delarosatrevin committed Jun 18, 2024
1 parent 0f2044a commit e8fbbb8
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 21 deletions.
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ Modules and Classes
.. toctree::
:maxdepth: 2

metadata <metadata/index>
utils <utils/index>
metadata <metadata/index>
jobs <jobs/index>




Expand Down
10 changes: 10 additions & 0 deletions docs/jobs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

jobs
====

.. toctree::
:maxdepth: 1

Pipeline <pipeline>


7 changes: 7 additions & 0 deletions docs/jobs/pipeline.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

Pipeline
========

.. autoclass:: emtools.jobs.Pipeline
:members:

6 changes: 4 additions & 2 deletions docs/metadata/starfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ that parsing rows if not needed. These methods will also create an index of wher
data blocks are in the file, so if you need to read a data table, it will jump to
that position in the file.

Reading a Table
---------------

Iterating over the rows
-----------------------
Iterating over the Table rows
-----------------------------

In some cases, we just want to iterate over the rows and operate on them one by one.
In that case, it is not necessary to fully load the whole table in memory. Iteration
Expand Down
6 changes: 4 additions & 2 deletions docs/utils/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ utils
.. toctree::
:maxdepth: 1

Color, Timer <misc>
Process <process>
Color, Pretty, Timer <misc>
Process, Path, System <process>


12 changes: 10 additions & 2 deletions docs/utils/misc.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@

Color, Pretty
=============
Color
=====

.. autoclass:: emtools.utils.Color
:members:

Pretty
======

.. autoclass:: emtools.utils.Pretty
:members:

Timer
=====

.. autoclass:: emtools.utils.Timer
:members:
13 changes: 9 additions & 4 deletions docs/utils/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
Process
=======

.. autoclass:: emtools.utils.Process
:members:

Path
====

Reference
---------

.. autoclass:: emtools.utils.Process
.. autoclass:: emtools.utils.Path
:members:

System
======

.. autoclass:: emtools.utils.System
:members:

3 changes: 3 additions & 0 deletions emtools/processing/__init__.py → emtools/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
# *
# **************************************************************************

from .pipeline import Pipeline

__all__ = ["Pipeline"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 6 additions & 5 deletions emtools/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
# **************************************************************************

from .color import Color
from .process import Process
from .pretty import Pretty
from .path import Path
from .time import Timer
from .pipeline import Pipeline

from .process import Process
from .path import Path
from .system import System

from .server import JsonTCPServer, JsonTCPClient


__all__ = [Color, Process, Pretty, Path, Timer, Pipeline, System,
JsonTCPServer, JsonTCPClient]
__all__ = ["Color", "Pretty", "Timer", "Process", "Path", "System",
"JsonTCPServer", "JsonTCPClient"]

3 changes: 3 additions & 0 deletions emtools/utils/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@


class Color:
""" Basic helper class to have colored string.
Useful for commands and log messages. """

@staticmethod
def green(msg):
return f'{OKGREEN}{msg}{ENDC}'
Expand Down
6 changes: 1 addition & 5 deletions emtools/utils/path.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@

import os
import time
from glob import glob
from datetime import datetime as dt
from datetime import timedelta
from collections import OrderedDict
import numpy as np

from .pretty import Pretty
from .process import Process
from .color import Color


class Path:
Expand Down Expand Up @@ -149,7 +145,7 @@ def _mkdir(d):
@staticmethod
def replaceExt(filename, newExt):
""" Replace the current path extension(from last .)
with a new one. The new one should not contains the ."""
with a new one. The new one should not contain the ."""
return Path.removeExt(filename) + '.' + newExt

@staticmethod
Expand Down
3 changes: 3 additions & 0 deletions emtools/utils/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@


class Pretty:
""" Helper class for "pretty" string formatting from several input types
(e.g. size, dates, timestamps, elapsed, etc.).
"""
# Default timestamp
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
DATE_FORMAT = '%Y-%m-%d'
Expand Down
4 changes: 4 additions & 0 deletions emtools/utils/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import socket
import platform
import psutil

from .process import Process


Expand All @@ -33,6 +34,7 @@ class System:

@staticmethod
def gpus():
""" Return a dictionary with existing GPUs and their properties. """
gpus = []
query = Process(System.NVIDIA_SMI_QUERY[0],
*System.NVIDIA_SMI_QUERY[1:], doRaise=False)
Expand Down Expand Up @@ -69,6 +71,7 @@ def cpus():

@staticmethod
def memory():
""" Return the total virtual memory of the system. (in Gb) """
return psutil.virtual_memory().total // (1024 * 1024 * 1024) # GiB

@staticmethod
Expand All @@ -92,4 +95,5 @@ def specs():

@staticmethod
def hostname():
""" Return the hostname. """
return socket.gethostname()

0 comments on commit e8fbbb8

Please sign in to comment.