Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
52b3c4d
started work on Hog metrical logger for Hold
SmithSamuelM Aug 27, 2025
2abd7c0
Some basic tests of Hog as subclass of Act and Filer
SmithSamuelM Aug 28, 2025
7983409
Added alias for Hog of log and Log in Act Registry
SmithSamuelM Aug 28, 2025
1913dd4
some clean up
SmithSamuelM Aug 29, 2025
662f6e7
clean up doc strings
SmithSamuelM Aug 29, 2025
642d267
clean up doc strings mroe
SmithSamuelM Aug 29, 2025
9d24058
more refinement of doc strings
SmithSamuelM Aug 29, 2025
d398cdd
added .act method to Hog
SmithSamuelM Aug 29, 2025
f35e83e
setup of attributes and parameters for Hog to log
SmithSamuelM Aug 29, 2025
57b7429
some clean up
SmithSamuelM Aug 30, 2025
6c0a5d5
more work on Hog hold log
SmithSamuelM Aug 30, 2025
bf50ebf
more comments
SmithSamuelM Aug 30, 2025
5758125
added boxer tyme bag in hold so record current boxer time and also pr…
SmithSamuelM Aug 31, 2025
4fae1ed
started work on hog header
SmithSamuelM Aug 31, 2025
a127d1c
fixed the pytest mocking problem
SmithSamuelM Aug 31, 2025
f360257
change hid to rid for run id not hog id since changes per run
SmithSamuelM Aug 31, 2025
5f1d365
fixed Hog.rid generation
SmithSamuelM Aug 31, 2025
394cefe
reordered boxer state addition of hold fields more work on Hog header
SmithSamuelM Sep 1, 2025
d6b5edd
more work on header
SmithSamuelM Sep 1, 2025
56b6182
more test cases
SmithSamuelM Sep 1, 2025
b6e1d63
changed rid to be base64 not hex
SmithSamuelM Sep 1, 2025
a8737d7
added logic for other log rules need to test
SmithSamuelM Sep 1, 2025
f7559e8
test Hog with vector bag
SmithSamuelM Sep 2, 2025
47a3813
fixed logic for update or change rule need to test
SmithSamuelM Sep 2, 2025
c0469c3
minor fix to mark logic in Hog
SmithSamuelM Sep 2, 2025
7bfadad
added tests for rule update
SmithSamuelM Sep 2, 2025
1f2e987
tests for chage rule
SmithSamuelM Sep 2, 2025
02c29d3
Tests for span rule
SmithSamuelM Sep 2, 2025
696ad28
added support for flush
SmithSamuelM Sep 2, 2025
323707c
Added CloseAct for closing instances at runtime in hier box used to c…
SmithSamuelM Sep 2, 2025
e03febf
added code for Hog log cycling need to test
SmithSamuelM Sep 3, 2025
491ca52
tests for cycling (rotating) logs now working
SmithSamuelM Sep 3, 2025
9c06b4f
fixed bug with registerify
SmithSamuelM Sep 3, 2025
9109cf9
file sizes not same on windows because of /r/n versus /n
SmithSamuelM Sep 3, 2025
badf26f
do not run log cycle tests on windows as all file size are different …
SmithSamuelM Sep 3, 2025
c802d4b
fixed logic mess up
SmithSamuelM Sep 3, 2025
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
3 changes: 2 additions & 1 deletion ref/hier.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ These properties are mutually supporting. Together they provide a powerful found
for solving the hard problem of automation systems, that is, the coordination
problem. The coordination problem poses the following question; how best to
coordinate the various components of an automation system especially
a coordiantion system that is dynamically adaptive (in-stride) to both a
a coordination system that is dynamically adaptive (in-stride) to both a
changing environment and changing goals and objectives for mission success?


Expand Down Expand Up @@ -107,6 +107,7 @@ A boxwork consists of a graph of connected boxes. Each box belongs to a pile of
stacked boxes. A given pile constitues a hierarchical state. State changes by
transitioning from one pile to a different pile as determined by a transition
from one box to another box in the boxwork.

### Box Piles

Each box may have an over box and zero or more under boxes. A box at the top
Expand Down
53 changes: 46 additions & 7 deletions src/hio/base/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class Filer(hioing.Mixin):
Mode (str): open mode such as "r+"
Fext (str): default file extension such as "text" for "fname.text"


Attributes:
name (str): unique path component used in directory or file path name
base (str): another unique path component inserted before name
temp (bool): True means use TempHeadDir in /tmp directory
headDirPath (str): head directory path
Expand All @@ -59,6 +57,12 @@ class Filer(hioing.Mixin):
opened (bool): True means directory created and if filed then file
is opened. False otherwise

Properties:
name (str): unique path component used in directory or file path name

Hidden:
_name (str): unique name for .name property


File/Directory Creation Mode Notes:
.Perm provides default restricted access permissions to directory and/or files
Expand Down Expand Up @@ -126,15 +130,17 @@ def __init__(self, *, name='main', base="", temp=False, headDirPath=None,
fext (str): File extension when filed or extensioned

"""
super(Filer, self).__init__(**kwa) # Mixin for Mult-inheritance MRO
if not hasattr(self, "_name") or name != self.name: # avoid collision subclass
self.name = name

super(Filer, self).__init__(name=self.name, **kwa) # Mixin for Mult-inheritance MRO

# ensure relative path parts are relative because of odd path.join behavior
if os.path.isabs(name):
raise hioing.FilerError(f"Not relative {name=} path.")
if os.path.isabs(self.name):
raise hioing.FilerError(f"Not relative name={self.name} path.")
if os.path.isabs(base):
raise hioing.FilerError(f"Not relative {base=} path.")

self.name = name
self.base = base
self.temp = True if temp else False
self.headDirPath = headDirPath if headDirPath is not None else self.HeadDirPath
Expand All @@ -150,6 +156,29 @@ def __init__(self, *, name='main', base="", temp=False, headDirPath=None,
if reopen:
self.reopen(clear=clear, reuse=reuse, clean=clean, **kwa)

@property
def name(self):
"""Property getter for ._name

Returns:
name (str): unique identifier of instance used as unique path
component in directory or file path name
"""
return self._name


@name.setter
def name(self, name):
"""Property setter for ._name

Parameters:
name (str): unique identifier of instance
"""
#if not Renam.match(name):
#raise HierError(f"Invalid {name=}.")
self._name = name



def reopen(self, temp=None, headDirPath=None, perm=None, clear=False,
reuse=False, clean=False, mode=None, fext=None, **kwa):
Expand Down Expand Up @@ -197,7 +226,7 @@ def reopen(self, temp=None, headDirPath=None, perm=None, clear=False,
mode=self.mode,
fext=self.fext,
**kwa)
elif self.filed: # assumes dir in self.path exists
elif self.filed: # would not be here unless self.path already exists
self.file = ocfn(self.path, mode=self.mode)

self.opened = True if not self.filed else self.file and not self.file.closed
Expand Down Expand Up @@ -450,13 +479,23 @@ def exists(self, name="", base="", headDirPath=None, clean=False,
return os.path.exists(path)


def flush(self):
"""
flush self.file if not closed
"""
if self.file and not self.file.closed:
self.file.flush()
os.fsync(self.file.fileno())


def close(self, clear=False):
"""Close .file if any and if clear rm directory or file at .path

Parameters:
clear (bool): True means remove dir or file at .path
"""
if self.file:
self.flush() # since file.close does not guarantee file sync
self.file.close()
self.opened = False

Expand Down
4 changes: 3 additions & 1 deletion src/hio/base/hier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
Act, Goact, EndAct, Beact, Mark, LapseMark, RelapseMark,
Count, Discount,
BagMark, UpdateMark, ReupdateMark,
ChangeMark, RechangeMark)
ChangeMark, RechangeMark,
CloseAct)
from .needing import Need
from .bagging import Bag, IceBag
from .canning import CanDom, Can
from .holding import Hold
from .durqing import Durq
from .dusqing import Dusq
from .hogging import Rules, Hog, openHog, HogDoer

Loading
Loading