Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
be64abc
Add reaction progression and detector stubs
janitha-mahanthe Jun 27, 2026
5b954e1
Merge branch 'main' into 0.3-ARXSession
janitha-mahanthe Jun 28, 2026
65d16df
Add PoolSpecies model and mol population helper
janitha-mahanthe Jun 28, 2026
a087fd2
Document PoolSpecies fields and mol population
janitha-mahanthe Jul 2, 2026
03ae6fb
Merge branch 'main' into 0.3-ARXSession
janitha-mahanthe Jul 6, 2026
4e04876
Merge branch 'main' into 0.3-ARXSession
janitha-mahanthe Jul 6, 2026
2f6d842
Add index-based functional group detector helper
janitha-mahanthe Jul 6, 2026
df45b60
Add index-based functional groups detector
janitha-mahanthe Jul 6, 2026
b537e59
Add DetectedChemistryFilter to collect chemistries
janitha-mahanthe Jul 6, 2026
986977e
Add epoxy/amine reaction rules and progression
janitha-mahanthe Jul 6, 2026
2489ddf
Add epoxy-amine FGs, atom indexes, and warning util
janitha-mahanthe Jul 7, 2026
a01caea
Add staged amine-epoxy reaction rules
janitha-mahanthe Jul 7, 2026
c2a93bc
WIP: add progressive chemistry rules skeleton
janitha-mahanthe Jul 7, 2026
7df0749
Add epoxy simulation example config
janitha-mahanthe Jul 9, 2026
8ab6dd8
Implement index-based functional group detection
janitha-mahanthe Jul 9, 2026
4b02a38
Clean reaction products in progression
janitha-mahanthe Jul 9, 2026
e6516ad
Add index-based reaction detection in progression
janitha-mahanthe Jul 9, 2026
5d86d4e
Add index-constrained reaction progression prep
janitha-mahanthe Jul 10, 2026
5004246
Refactor prepare_reactions.py code style
janitha-mahanthe Jul 10, 2026
1fa9111
Fix product idx remapping for multi-fragment products
janitha-mahanthe Jul 10, 2026
7f77e7e
Remove unused detectors and processor files
janitha-mahanthe Jul 10, 2026
fcfe4a0
Add DeduplicationDetector for reactions
janitha-mahanthe Jul 10, 2026
33adcd3
Add RDKit reaction dedup across progression
janitha-mahanthe Jul 13, 2026
9259d09
Update deduplication_detector.py
janitha-mahanthe Jul 13, 2026
c262190
Refactor reaction_progression for clarity
janitha-mahanthe Jul 14, 2026
4fb669d
Refactor reaction progression logic
janitha-mahanthe Jul 14, 2026
fb1d557
Refine reaction progression loop state handling
janitha-mahanthe Jul 14, 2026
5f350a7
Add uncoupled pair-based duplicate detection
janitha-mahanthe Jul 14, 2026
7d50276
Fix forced-reaction mode for same reactants
janitha-mahanthe Jul 14, 2026
1b4f574
Update test_epoxy.json
janitha-mahanthe Jul 14, 2026
b9f4ae7
Update functional_groups_detector.py
janitha-mahanthe Jul 14, 2026
fb47faa
Refine deduplication cache behavior
janitha-mahanthe Jul 14, 2026
2c8e153
Delete fragment_comparison.py
janitha-mahanthe Jul 14, 2026
03b9d07
Raise error when no reactions are active
janitha-mahanthe Jul 14, 2026
66bd8cf
Refine reaction progression loop
janitha-mahanthe Jul 14, 2026
61c0df2
Fix progression deduplication handling
janitha-mahanthe Jul 14, 2026
b25fe07
Remove noisy debug output
janitha-mahanthe Jul 14, 2026
339638c
Potential fix for pull request finding
janitha-mahanthe Jul 14, 2026
070cc31
Potential fix for pull request finding
janitha-mahanthe Jul 14, 2026
8497c38
Potential fix for pull request finding
janitha-mahanthe Jul 14, 2026
0a52366
Potential fix for pull request finding
janitha-mahanthe Jul 14, 2026
bbfa638
Potential fix for pull request finding
janitha-mahanthe Jul 14, 2026
0450d2f
Potential fix for pull request finding
janitha-mahanthe Jul 14, 2026
7ff392f
Potential fix for pull request finding
janitha-mahanthe Jul 14, 2026
fe39077
Remove unused numpy indices import
Copilot Jul 14, 2026
e865c75
Refactor forced index handling in prepare_reactions.py
janitha-mahanthe Jul 14, 2026
f828e69
Potential fix for pull request finding
janitha-mahanthe Jul 14, 2026
d488f58
Merge pull request #100 from NanoCIPHER-Lab/0.3-ARXSession
janitha-mahanthe Jul 14, 2026
f425265
Add vinyl polymerization reaction support
janitha-mahanthe Jul 14, 2026
8f9c279
Fix vinyl polymerization SMARTS and radical handling
janitha-mahanthe Jul 14, 2026
8c3f4ad
Create test_styrene.json
janitha-mahanthe Jul 14, 2026
ff25387
Improve 3D molecule prep and add repair step
janitha-mahanthe Jul 15, 2026
735c20a
Generalize vinyl radical SMARTS patterns
janitha-mahanthe Jul 15, 2026
e6cd09c
Make RDKit deduplication radical-aware
janitha-mahanthe Jul 15, 2026
584e6aa
Track radical atoms before reaction dedup
janitha-mahanthe Jul 15, 2026
e52f82f
Add loop controls for reaction progression
janitha-mahanthe Jul 15, 2026
3602aaa
Refine loop parsing and trim debug output
janitha-mahanthe Jul 15, 2026
80532a8
Fix vinyl radical type and expand parser tests
janitha-mahanthe Jul 15, 2026
6960e27
Remove legacy compatibility shim
janitha-mahanthe Jul 15, 2026
7f97a23
Refresh warning banner ASCII art
janitha-mahanthe Jul 15, 2026
91a5b7f
Refactor reaction progression and docs
janitha-mahanthe Jul 20, 2026
ef489e1
Refactor reaction preparation workflow
janitha-mahanthe Jul 20, 2026
50e1c67
Fix epoxy polymer reaction rules
janitha-mahanthe Jul 21, 2026
19abeb7
Add registries for groups and reactions
janitha-mahanthe Jul 21, 2026
8f85eae
Add package exports for detector libraries
janitha-mahanthe Jul 21, 2026
31e15b4
Add polyamide reaction library
janitha-mahanthe Jul 21, 2026
13b70d9
Add mixed AB groups and polymer reaction libraries
janitha-mahanthe Jul 21, 2026
90e9792
Add nitrogen functional groups library
janitha-mahanthe Jul 21, 2026
59c8200
Update registry.py
janitha-mahanthe Jul 21, 2026
92ad793
Add polycarbonate synthesis pathways
janitha-mahanthe Jul 21, 2026
3fa18ed
Fix phosgene SMARTS to prevent partial matches
janitha-mahanthe Jul 21, 2026
126dedc
Add polyester polycondensation reaction library
janitha-mahanthe Jul 22, 2026
0f8f49c
Add polysiloxane reactions, disable draft modules
janitha-mahanthe Jul 22, 2026
9f82c8d
Disable untested halide and polysulfide entries
janitha-mahanthe Jul 22, 2026
ead2824
Add polythioester reaction library entries
janitha-mahanthe Jul 22, 2026
38052b9
Add functional groups and polyurea reaction
janitha-mahanthe Jul 22, 2026
49bb79a
Add polyurethanes reactions library module
janitha-mahanthe Jul 22, 2026
a6fd6a2
Update polyurethanes.py
janitha-mahanthe Jul 22, 2026
c4de1ed
Improve embedding for congested polymers
janitha-mahanthe Jul 24, 2026
29da8c9
Add vinyl polymer reaction library definitions
janitha-mahanthe Jul 24, 2026
b12183f
Add new functional group library modules
janitha-mahanthe Jul 24, 2026
f49b0c3
Refactor reaction libraries into package modules
janitha-mahanthe Jul 24, 2026
6c418ee
Disable aromatic group registration
janitha-mahanthe Jul 24, 2026
ab4281f
Add ring/silicon groups and normalize defs
janitha-mahanthe Jul 24, 2026
99fc398
Normalize polymer reaction library entries
janitha-mahanthe Jul 24, 2026
f2fb2f6
Normalization
janitha-mahanthe Jul 24, 2026
d48858b
Create thiol_ene_polymers.py
janitha-mahanthe Jul 24, 2026
cd2f3c8
Potential fix for pull request finding
janitha-mahanthe Jul 24, 2026
adc3739
Potential fix for pull request finding
janitha-mahanthe Jul 24, 2026
8ae3698
Potential fix for pull request finding
janitha-mahanthe Jul 24, 2026
dc12f88
Potential fix for pull request finding
janitha-mahanthe Jul 24, 2026
188d51a
Potential fix for pull request finding
janitha-mahanthe Jul 24, 2026
b16c63f
Potential fix for pull request finding
janitha-mahanthe Jul 24, 2026
d7ae649
Merge pull request #102 from NanoCIPHER-Lab/0.3-vinyl-dev
janitha-mahanthe Jul 24, 2026
5f7d612
Add TFE vinyl polymerization support
janitha-mahanthe Jul 24, 2026
71b2a3b
Bump to v0.3 and update reaction workflows
janitha-mahanthe Jul 27, 2026
014e3e0
Add LAMMPS template deduplication step
janitha-mahanthe Jul 27, 2026
8cce4dd
Add s_m sulfone params to PCFF force field
janitha-mahanthe Jul 28, 2026
a5f5f80
Improve reaction/merge handling and PCFF params
janitha-mahanthe Jul 28, 2026
90f4a5d
Add changelog entry for v0.3
janitha-mahanthe Jul 28, 2026
5a330b8
Use full atom count (H included) for num_atoms
janitha-mahanthe Jul 28, 2026
7d37cff
Add input snapshot and polymerization updates
janitha-mahanthe Jul 29, 2026
5e2a153
Disable transesterification and tweak equilibration
janitha-mahanthe Jul 31, 2026
7a310fe
Validate reaction initiator atom maps
janitha-mahanthe Aug 4, 2026
18c3386
Add LAMMPS map-based template deduplication
janitha-mahanthe Aug 4, 2026
f1ca90a
Potential fix for pull request finding
janitha-mahanthe Aug 7, 2026
bb12d91
Potential fix for pull request finding
janitha-mahanthe Aug 7, 2026
73ea96a
Potential fix for pull request finding
janitha-mahanthe Aug 7, 2026
24837c0
Potential fix for pull request finding
janitha-mahanthe Aug 7, 2026
e8ee361
Move file paths into domain dataclasses
janitha-mahanthe Aug 14, 2026
0fd8215
Fix cached LUNAR molecule file handling
janitha-mahanthe Aug 14, 2026
d1256f3
Rebuild REACTER file wrappers during output copy
janitha-mahanthe Aug 14, 2026
66dc381
Remove legacy REACTER file wrapper types
janitha-mahanthe Aug 14, 2026
2703656
Simplify REACTERFiles to store metadata directly
janitha-mahanthe Aug 14, 2026
63a2438
Fix writer paths for reaction template files
janitha-mahanthe Aug 14, 2026
17a8295
Fix molecule file copy guard in densification
janitha-mahanthe Aug 14, 2026
e865832
Filter inactive reaction templates in pipeline
janitha-mahanthe Aug 14, 2026
85f939e
Disable vinyl termination and rename initiation
janitha-mahanthe Aug 14, 2026
181efef
Add reaction workflow options to session setup
janitha-mahanthe Aug 14, 2026
9bcf3ae
Add deep search and iteration depth settings
janitha-mahanthe Aug 14, 2026
c994808
Refactor loop/iteration depth validation
janitha-mahanthe Aug 14, 2026
6e1a974
Move workflow flags out of Session state
janitha-mahanthe Aug 14, 2026
e68dcc4
Sync session options and output paths
janitha-mahanthe Aug 14, 2026
ecde0c3
Handle loop depth and add session counters
janitha-mahanthe Aug 14, 2026
ef4f1e7
Refine dedup and progression controls
janitha-mahanthe Aug 14, 2026
b8571a6
Update input_parser.py
janitha-mahanthe Aug 14, 2026
44243cd
Add wildcard-aware LAMMPS deduplication
janitha-mahanthe Aug 14, 2026
c6a1948
Add wildcard map support for templates
janitha-mahanthe Aug 14, 2026
bdf188c
Skip second reaction stage when disabled
janitha-mahanthe Aug 14, 2026
cf6822d
Refine second-stage LAMMPS script generation
janitha-mahanthe Aug 14, 2026
48b2114
Add TMC/MPD example, fix bugs, refactor reactions
janitha-mahanthe Aug 17, 2026
b4c5626
Merge pull request #107 from NanoCIPHER-Lab/0.3-dev-refacter-lmp-files
janitha-mahanthe Aug 17, 2026
a088d02
Fix vinyl polymer reactions dict and add docs page
janitha-mahanthe Aug 18, 2026
7767c4f
Add deep-check toggle and advanced options docs
janitha-mahanthe Aug 18, 2026
1e9cac1
Remove debug print on reaction fallback
janitha-mahanthe Aug 18, 2026
d42a855
Document advanced options and dedupe
janitha-mahanthe Aug 18, 2026
cbd669f
Add example configs and docs assets
janitha-mahanthe Aug 19, 2026
d1dbc0f
Add unit tests for functional group detection
janitha-mahanthe Aug 19, 2026
302343f
Add detector-focused functional group tests
janitha-mahanthe Aug 19, 2026
faae321
Add functional group library unit tests
janitha-mahanthe Aug 19, 2026
dda17fc
Add unit tests for detector behaviors
janitha-mahanthe Aug 19, 2026
f19c919
Remove deprecated detector workflow module
janitha-mahanthe Aug 19, 2026
7e71d78
Add unit tests for all reaction library modules
janitha-mahanthe Aug 19, 2026
a842806
Create test_registry.py
janitha-mahanthe Aug 19, 2026
ea96f41
Remove input parser and lunar wrapper tests
janitha-mahanthe Aug 19, 2026
f17df4c
Add unit tests and refactor input_parser.py
janitha-mahanthe Aug 19, 2026
5680142
Respect cache staging clear flag
janitha-mahanthe Aug 19, 2026
59e358c
Create test_arx_cli.py
janitha-mahanthe Aug 19, 2026
412fac4
Improve stdout capture in ARXCLI
janitha-mahanthe Aug 19, 2026
cb719ff
Export session in public API
janitha-mahanthe Aug 19, 2026
568b490
Fix index alignment bugs and add unit tests
janitha-mahanthe Aug 19, 2026
7391790
Add walker tests, reorganize test structure
janitha-mahanthe Aug 19, 2026
225b3d7
Update test_walker.py
janitha-mahanthe Aug 19, 2026
4384231
Add unit tests for reaction preparation modules
janitha-mahanthe Aug 19, 2026
1ca98b4
Add unit tests for LUNAR client utilities
janitha-mahanthe Aug 19, 2026
50e1d34
Add unit tests for ff_wrapper components
janitha-mahanthe Aug 19, 2026
cc4b0e1
Add unit tests and clarify DeleteIDs map handling
janitha-mahanthe Aug 19, 2026
ced912b
Add writer tests and disable stage 2 by default
janitha-mahanthe Aug 19, 2026
baab554
Merge pull request #108 from NanoCIPHER-Lab/0.3-write-unit-tests
janitha-mahanthe Aug 19, 2026
daed3f7
Clean example input files for v0.3
Aug 19, 2026
d96063f
Refresh API docs and example notebook flow
janitha-mahanthe Aug 19, 2026
a249b2c
Fix typo in README workflow description
janitha-mahanthe Aug 20, 2026
cde3b26
Update version number to v0.3 in README
janitha-mahanthe Aug 20, 2026
3ff8420
Restructure documentation pages
janitha-mahanthe Aug 20, 2026
f89a11d
Add v0.3.0 reaction progression workflow
janitha-mahanthe Aug 20, 2026
11ed556
Refresh README quick start guide
janitha-mahanthe Aug 21, 2026
c639c3d
Update example_1.py
janitha-mahanthe Aug 21, 2026
fbcbace
Remove workflow flags from Session model
janitha-mahanthe Aug 21, 2026
9c60db2
Refine session runtime default test coverage
janitha-mahanthe Aug 21, 2026
e146f38
Update advanced_options.md
janitha-mahanthe Aug 31, 2026
b6d7926
Clarify active reaction map usage
janitha-mahanthe Aug 31, 2026
a50c8d7
Update REACTER_files_builder.py
janitha-mahanthe Aug 31, 2026
c239701
Update deduplication_detector.py
janitha-mahanthe Aug 31, 2026
7b99a9a
Update REACTER_files_builder.py
janitha-mahanthe Aug 31, 2026
12d25dd
Format mixed AB group entries
janitha-mahanthe Sep 2, 2026
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
5 changes: 3 additions & 2 deletions AutoREACTER/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

AutoREACTER is a tool for automated reaction-based molecular system generation.
"""
__version__ = "0.2.3"
__version__ = "0.3"

__title__ = "AutoREACTER"
__author__ = "Janitha Mahanthe, Jacob Gissinger"
Expand Down Expand Up @@ -304,6 +304,7 @@ def process() -> None:
"__authors__",
"__license__",
"run",
"session",
"show_molecules",
"show_functional_groups",
"show_reactions",
Expand All @@ -313,4 +314,4 @@ def process() -> None:
"prepare_reactions",
"show_reaction_templates",
"process",
]
]
60 changes: 0 additions & 60 deletions AutoREACTER/_compat.py

This file was deleted.

200 changes: 158 additions & 42 deletions AutoREACTER/arx_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from contextlib import contextmanager
import os
from pathlib import Path
import shutil
import sys
import threading
from PIL import Image
Expand All @@ -30,6 +31,9 @@
from AutoREACTER.reaction_preparation.ff_wrapper.REACTER_files_builder import REACTERFilesBuilder
from AutoREACTER.sim_setup.simulation_setup import SimulationSetupManager

class NoReactionGenerated(Exception):
"""Custom exception raised when no reaction is generated in the pipeline."""
pass

class ErrorHandler:
"""
Expand Down Expand Up @@ -98,7 +102,8 @@ def __init__(self, input: Path) -> None:
self.img_dir = self.session.images_dir
# with open(self.session.output_dir / "AutoREACTER.log", 'w') as f:
# f.write("--- Starting AutoREACTER Session ---\n")

# Save a copy of the input JSON to the output directory
self._save_input_json(abs_path)
# Save an initial grid image of all monomers
self._save_rdkit_img(
InputParser().initial_molecules_image_grid(self.session),
Expand Down Expand Up @@ -241,14 +246,6 @@ def prepare_reactions(self) -> None:
"""
PrepareReactions(self.session).prepare_reactions(self.session)
self.error_handler["process"] = True
highlight_types = ["template", "edge", "initiators", "delete"]
for highlight_type in highlight_types:
img = PrepareReactions(self.session).reaction_templates_highlighted_image_grid(
self.session, highlight_type=highlight_type
)
self._save_rdkit_img(
img, self.img_dir / f"templates_{highlight_type}.png"
)
return None

def show_reaction_templates(self, highlight_type: str = "template") -> Image:
Expand Down Expand Up @@ -311,9 +308,24 @@ def process(self):

SimulationSetupManager().setup_and_write_simulation(self.session)

highlight_types = ["template", "edge", "initiators", "delete"]
for highlight_type in highlight_types:
img = PrepareReactions(self.session).reaction_templates_highlighted_image_grid(
self.session, highlight_type=highlight_type
)
self._save_rdkit_img(
img, self.img_dir / f"templates_{highlight_type}.png"
)

self.error_handler["process"] = True

# ------------------------------------------------------------------
# Internal helpers – lazy detection & image saving
# ------------------------------------------------------------------
def _save_input_json(self, abs_path: Path):
destination_file = "input.json"
destination_path = self.session.output_dir / destination_file
shutil.copy(abs_path, destination_path)

def _ensure_fg_detected(self):
"""
Expand Down Expand Up @@ -384,7 +396,10 @@ def _save_rdkit_img(self, img, path: Path, is_non_reactant: bool = False):
if img is None:
if is_non_reactant:
return
raise ValueError("No image was generated. Cannot save molecule image.")
raise NoReactionGenerated(
"No reaction was generated. This is an error from AutoREACTER. "
"Please file an issue on https://github.com/NanoCIPHER-Lab/AutoREACTER/issues to improve the software."
)

# Case 1: PIL image
if hasattr(img, "save"):
Expand Down Expand Up @@ -430,59 +445,160 @@ def _writer(self, filename="AutoREACTER.log"):
self.session.output_dir.mkdir(parents=True, exist_ok=True)
log_path = self.session.output_dir / filename

# 1. Save the original OS-level terminal output
# Save both Python's stdout object and the original OS-level stdout.
#
# These are not always the same destination. For example, pytest,
# Jupyter, and other environments may replace sys.stdout with their
# own wrapper while file descriptor 1 still exists separately.
original_stdout = sys.stdout
original_stdout_fd = os.dup(1)

# 2. Create an OS-level pipe (a temporary tunnel for our data)
# Create an OS-level pipe. Both Python print() output and raw fd-1
# output will be redirected into this pipe.
pipe_read_fd, pipe_write_fd = os.pipe()

redirected_stdout = None

def write_to_original_stdout(data: bytes) -> None:
"""
Forward captured output back to the original visible stdout.

If the original Python stdout directly represents fd 1, write to
the saved duplicate of fd 1. Otherwise, use the original Python
stdout object so capture systems such as pytest/Jupyter still see
the output.
"""
try:
original_fileno = original_stdout.fileno()
except (AttributeError, OSError, ValueError):
original_fileno = None

if original_fileno == 1:
os.write(original_stdout_fd, data)
return

text = data.decode(
"utf-8",
errors="replace",
)

original_stdout.write(text)
original_stdout.flush()

def tee_thread():
"""Background worker that reads the pipe and writes to both destinations."""
with open(log_path, 'a') as log_file:
"""
Background worker that reads the pipe and writes to both
the original output destination and the log file.
"""
with open(
log_path,
"a",
encoding="utf-8",
) as log_file:
while True:
# Read incoming data from the pipe
data = os.read(pipe_read_fd, 1024)

data = os.read(
pipe_read_fd,
1024,
)

# If the pipe is closed, stop the thread
if not data:
break

# Write to the actual terminal
os.write(original_stdout_fd, data)


# Write to the original terminal / stdout capture
write_to_original_stdout(
data
)

# Write to the log file
log_file.write(data.decode('utf-8', errors='replace'))
log_file.write(
data.decode(
"utf-8",
errors="replace",
)
)
log_file.flush()

# 3. Start the background thread
thread = threading.Thread(target=tee_thread)
# Start the background tee worker
thread = threading.Thread(
target=tee_thread
)
thread.start()

# Flush Python's buffers before we switch the tracks
sys.stdout.flush()
# Flush Python's current stdout before changing destinations
original_stdout.flush()

try:
# 4. Redirect all OS-level output to the write-end of our pipe
os.dup2(pipe_write_fd, 1)
# Redirect OS-level stdout (fd 1) into the pipe.
#
# This captures subprocess output, os.write(1, ...), native
# library output, and anything else that writes directly to
# standard output.
os.dup2(
pipe_write_fd,
1,
)

# Redirect Python's sys.stdout explicitly as well.
#
# This is necessary because environments such as pytest and
# Jupyter can replace sys.stdout with an object that does not
# automatically follow changes made to file descriptor 1.
redirected_stdout = os.fdopen(
os.dup(1),
"w",
buffering=1,
encoding=getattr(
original_stdout,
"encoding",
None,
)
or "utf-8",
errors="replace",
)

sys.stdout = redirected_stdout

yield

finally:
# Flush Python buffers one last time
sys.stdout.flush()

# 5. Restore the original terminal output
os.dup2(original_stdout_fd, 1)

# 6. Close the write end of the pipe (this tells the thread to stop)
os.close(pipe_write_fd)

# 7. Wait for the thread to finish processing the last bits of data
# Flush all pending Python output into the pipe
if redirected_stdout is not None:
redirected_stdout.flush()

# Restore Python's original stdout object first
sys.stdout = original_stdout

# Close the duplicated Python pipe writer
if redirected_stdout is not None:
redirected_stdout.close()

# Restore OS-level stdout
os.dup2(
original_stdout_fd,
1,
)

# Close the original pipe write descriptor.
#
# Once every write descriptor pointing at the pipe is closed,
# the background thread receives EOF and exits.
os.close(
pipe_write_fd
)

# Wait until the final buffered output has been copied
thread.join()

# 8. Clean up remaining file descriptors
os.close(pipe_read_fd)
os.close(original_stdout_fd)

# Clean up remaining file descriptors
os.close(
pipe_read_fd
)

os.close(
original_stdout_fd
)
# ------------------------------------------------------------------
# Magic Methods
# ------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion AutoREACTER/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def __init__(self, clear_staging: bool = True):
# generate a unique staging directory for this run to prevent concurrent conflicts
self.staging_dir = Path(tempfile.gettempdir()) / f"AutoREACTER_staging"
self.staging_dir.mkdir(parents=True, exist_ok=True)
self.clear_staging_dir()

if clear_staging:
self.clear_staging_dir()

def clear_staging_dir(self) -> None:
"""
Expand Down
Loading