woger package¶
Submodules¶
- woger.action_status module
- woger.action_tracker module
- woger.base_data module
- woger.base_path_structure module
- woger.bind module
- woger.constants module
- woger.data_meta module
- woger.loaders module
- woger.manager module
- woger.path_structure_meta module
- woger.state module
- woger.storage module
- woger.workspace module
Module contents¶
-
class
woger.
Workspace
(data)[source]¶ Bases:
object
Wrapper interface to store path and data
-
id
¶ int or str
-
root
¶ str
-
path
¶ BasePathStructure
-
data
¶ BaseData
Examples
Workspace with chained loaders
-
classmethod
construct
(root, path_structure_cls=None, data_cls=None)[source]¶ Creates a Workspace object
Convinient alternative constructor
-
id
Workspace id
Id is used to sort workspaces from oldest to latest
-
path
Bound path structure object
-
root
Workspace root
-
-
class
woger.
WorkspaceState
(path: str)[source]¶ Bases:
object
Manages workspace state
State is written to file each time anything changes
-
path
¶ str – Path of the file to store the state in
-
-
class
woger.
WorkspaceStorage
(workspaces: typing.Union[typing.Iterable[woger.workspace.Workspace], NoneType] = None, limit: typing.Union[int, NoneType] = None)[source]¶ Bases:
object
Stores workspaces
-
add
(workspace: woger.workspace.Workspace)[source]¶ Add a workspace
Parameters: workspace (Workspace) – Workspace to be added
-
at
(index) → typing.Union[woger.workspace.Workspace, NoneType][source]¶ Gets workspace from storage by index
To get the oldest workspace use index 0 To get the latest workspace use index -1
-
classmethod
load_from_directory
(root, *, path_structure_cls=None, data_cls=None, workspace_cls=None)[source]¶ Creates a workspaces instance and loads all the workspaces from the root path
-
root
¶ str – Storage root path
-
path_structure_cls
¶ BasePathStructure class object
-
data_cls
¶ BaseData class object
-
workspace_cls
¶ Workspace class object
-
-
-
class
woger.
WorkspaceManager
(root, path_structure_cls=None, data_cls=None, workspace_cls=None)[source]¶ Bases:
object
Manages workspaces
Allows you to - create workspaces - load workspaces from directory - manage current, target and latest workspaces - search for workspaces with finished actions
Examples
-
create
(ws_id) → woger.workspace.Workspace[source]¶ Creates a Workspace
Parameters: ws_id (str or int) – Workspace id
-
current_ws_id
¶ Returns current workspace id
-
find_latest_finished
(action) → typing.Union[woger.workspace.Workspace, NoneType][source]¶ Searches for latest workspace with finished action action
-
target_ws_id
¶ Returns target workspace id
-
-
class
woger.
ActionTracker
(action: str, state_path: str, path=None)[source]¶ Bases:
object
Manages and monitors actions
-
state
¶ WorkspaceState object linked to self.state_path
-
-
class
woger.
ActionStatus
[source]¶ Bases:
enum.Enum
List of action statuses
-
failed
= 'failed'¶
-
finished
= 'finished'¶
-
started
= 'started'¶
-
undefined
= None¶
-
-
class
woger.
BasePathStructure
(root: str, *, data=None)[source]¶ Bases:
object
Base class for the path structure
-
track
(action: str) → woger.action_tracker.ActionTracker[source]¶ Creates an ActionTracker object and targets action action
It’s a shortcut which creates an ActionTracker for you
..code-block:: python
>>> from woger import BasePathStructure >>> >>> class PathStructure(BasePathStructure): ... json = 'json' >>> >>> ps = PathStructure('root') >>> >>> # WRONG >>> tracker = ActionTracker('load_json', 'root/state.json', ps.json) >>> >>> # RIGHT >>> tracker = ps.track(ps.json.action())
Parameters: action (str) – Action to track Returns: Return type: ActionTracker instance
-