pyretis.bin¶
Here, the PyRETIS executables can be found. These are:
pyretis.bin.cli module¶
pyretis - The unified PyRETIS command-line interface.
This is the single entry point for PyRETIS. It dispatches a sub-command to the matching tool:
pyretis run -i input.toml # run a simulation (was pyretisrun)
pyretis analyse -i analysis.txt # analyse output (was pyretisanalyse)
pyretis clean # remove run artifacts in a directory
The run and analyse sub-commands take exactly the same options as
the standalone command they replace; pyretis <command> -h shows them.
The standalone pyretisrun and pyretisanalyse commands still work
but are deprecated: from PyRETIS 5 only pyretis run and
pyretis analyse will be supported.
pyretis.bin.pyretisrun module¶
pyretisrun - An application for running PyRETIS simulations.
This script is a part of the PyRETIS library and can be used for running simulations from an input script.
usage: pyretisrun.py [-h] -i INPUT [-V] [-f LOG_FILE] [-l LOG_LEVEL] [-p]
PyRETIS
- optional arguments:
- -h, --help
show this help message and exit
- -i INPUT, --input INPUT
Location of PyRETIS input file
- -V, --version
show program’s version number and exit
- -f LOG_FILE, --log_file LOG_FILE
Specify log file to write
- -l LOG_LEVEL, --log_level LOG_LEVEL
Specify log level for log file
- -p, --progress
Display a progress meter instead of text output for the simulation
More information about running PyRETIS can be found at: www.pyretis.org
- pyretis.bin.pyretisrun._apply_restart_steps(restart_file, steps)[source]¶
Set the step target in a scheduler run file in place.
On a continuation the native config carries the new (usually higher) total step target. The scheduler stops once
cstepreaches[simulation] steps, so a resumed restart must adopt the new target or it would have nothing left to run. This reads, updates and rewrites the run TOML (output.toml, or a legacyrestart.toml), leaving every other key (the persistedcurrentstate – RNG, frac, active paths – and all settings) untouched.- Parameters:
restart_file (string) – Path to the scheduler run file (
output.tomlor a legacyrestart.toml).steps (int) – The new total step target to write into
[simulation] steps.
- pyretis.bin.pyretisrun._report_execution_error(error, log_level)[source]¶
Log a stopped execution and write its traceback to the log only.
Shared by both CLI flows (the native in-process simulation and the infinite-swapping scheduler) so a failure is reported the same way regardless of which path ran. The friendly one-line message goes to the screen; the full traceback goes to the log file only.
- Parameters:
error (Exception) – The exception currently being handled.
log_level (integer) – The active log level. At
DEBUGor below the caller should re-raise so the traceback also reaches the screen.
- Returns:
reraise (boolean) –
Truewhen the caller should re-raise (debug mode), so the error is never silently swallowed.
- pyretis.bin.pyretisrun._warn_infretis_dialect_deprecated(inputfile)[source]¶
Emit a single
DeprecationWarningfor infretis-flavour input.Mirrors
pyretis.inout.settings._warn_rst_deprecated()’s rst precedent: the legacy dialect keeps running (via the same normalize/translate pipeline every native config already goes through, seerun_infretis_flavour_config()), this only warns.
- pyretis.bin.pyretisrun.entry_point()[source]¶
entry_point - The entry point for the pip install of pyretisrun.
- pyretis.bin.pyretisrun.entry_point_deprecated()[source]¶
Legacy
pyretisrunentry point: warn, then runpyretis run.The standalone
pyretisruncommand is kept working for now but is deprecated in favour ofpyretis run; from PyRETIS 5 only the unified command will be supported. This wrapper emits that warning and then delegates toentry_point()unchanged.
- pyretis.bin.pyretisrun.hello_world(infile, rundir, logfile)[source]¶
Print out a politically correct greeting for PyRETIS.
- Parameters:
infile (string) – String showing the location of the input file.
rundir (string) – String showing the location we are running in.
logfile (string) – The output log file
- pyretis.bin.pyretisrun.is_infinite_swapping_config(inputfile)[source]¶
Return True if the input selects the infinite-swapping sampler.
The infinite-swapping (replica-exchange) sampler is selected explicitly via
[simulation] task = "infinite_swapping"(orinfswap/infretis). A recognised native path-sampling task (_NATIVE_SCHEDULER_TASKS: retis/tis/explore/pptis/repptis) is NEVER treated as infinite-swapping, even if its[runner]section is present –[runner](worker count / multi-engine pools) is legal native syntax too, translated bypyretis.inout.config_adapter.native_to_infswap_config()just like every other native section. Only an input with NO recognisedtaskat all falls back to the[runner]-presence heuristic (the still-supported legacy infretis-flavour dialect, which never setstask). Only.tomlinputs are considered; the in-process simulation flow handles everything else.- Parameters:
inputfile (string) – Path to the input file.
- Returns:
boolean – True if the infinite-swapping scheduler should run this input.
- pyretis.bin.pyretisrun.is_infretis_flavour_config(inputfile)[source]¶
Return True if
inputfileneeds the infretis-flavour pipeline.The structural marker is
[simulation.tis_set]– the infretis-flavour dialect’s own placement of its path-sampling knobs (vs. native’s[tis]) – checked directly rather than inferred fromtask: real configs in the validation suite carry an explicittask = "infinite_swapping"for unambiguous routing while still using[simulation.tis_set]throughout, sotaskpresence alone does not distinguish the two dialects here (see MERGE_TODO.md S5.6).A restart continuation is excluded: it is always invoked by pointing
-idirectly at the scheduler’s ownrestart.toml(never the original config), which is already in the coordinator’s own shape (its[current]section is state, not input) and must not be re-normalized. Both the conventional filename and[current]’s presence are checked, since the restart-continuation convention inpyretis.simulation.setup.setup_config()already depends on the exactrestart.tomlname, not just this function.- Parameters:
inputfile (string) – Path to the input file.
- Returns:
boolean – True if this is a fresh infretis-flavour config that should be routed through
run_infretis_flavour_config().
- pyretis.bin.pyretisrun.is_native_scheduler_config(inputfile)[source]¶
Return True if a native path-sampling TOML routes to the scheduler.
As of the Stage C collapse, native
task = "retis".tomlinputs are run through the infinite-swapping scheduler atn_workers = 1(their config is translated bypyretis.inout.config_adapter.native_to_infswap_config()). The nativetis,explore,pptis, andrepptistasks all route through the scheduler too (validated by VALIDITY, not byte-identity – the coordinator RNG differs from the native loop’s). Inputs that already select the infinite-swapping sampler are excluded. A native path-sampling config that hits a scheduler PORT GAP (seenative_scheduler_port_gap()) returnsFalsehere and is rejected with a clear error by the caller – it is NOT dispatched to the retired in-process loop. Only.tomlinputs are considered (a.rstinput is not a scheduler config).- Parameters:
inputfile (string) – Path to the input file.
- Returns:
boolean – True for a native path-sampling
.tomlthe scheduler can run.
- pyretis.bin.pyretisrun.main(infile, indir, exe_dir, progress, log_level)[source]¶
Execute PyRETIS.
- Parameters:
infile (string) – The input file to open with settings for PyRETIS.
indir (string) – The folder containing the settings file.
exe_dir (string) – The directory we are working from.
progress (boolean) – Determines if we should use a progress bar or not.
log_level (integer) – Determines if we should display the error traceback or not.
- pyretis.bin.pyretisrun.make_tis_files(_, settings, progress=False)[source]¶
Create TIS simulations input files PyRETIS.
- It just writes out input files for single TIS simulations and
exit without running a simulation.
- Parameters:
settings (list of dicts or Simulation objects) – The settings for the simulations.
- pyretis.bin.pyretisrun.native_scheduler_port_gap(inputfile)[source]¶
Return the scheduler port-gap reason for a native path-sampling TOML.
A native path-sampling task (tis/retis/explore/pptis/repptis) whose config the scheduler cannot yet run (see
scheduler_supported_features()) has NO execution path – the native in-process loop is retired – so the caller must reject it with this reason rather than dispatch the retired loop. ReturnsNonefor inputs that are not native path-sampling.tomltasks (md/md-flux/ a.rstinput / an infinite-swapping config), which run their normal route, andNonefor a native path-sampling config the scheduler does cover.- Parameters:
inputfile (string) – Path to the input file.
- Returns:
string or None – The first unsupported-feature reason, or
None.
- pyretis.bin.pyretisrun.remove_exit_file(exit_file)[source]¶
Remove the EXIT file after a completed soft exit.
- pyretis.bin.pyretisrun.run_generic_simulation(sim, sim_settings, progress=False)[source]¶
Run a generic PyRETIS simulation.
These are simulations that are just going to complete a given number of steps. Other simulation may consist of several simulations tied together and these are NOT handled here.
- Parameters:
sim (object like
Simulation) – This is the simulation to run.sim_settings (dict) – The simulation settings.
progress (boolean, optional) – If True, we will display a progress bar, otherwise, we print results to the screen.
- pyretis.bin.pyretisrun.run_infinite_swapping(inputfile)[source]¶
Run an infinite-swapping (replica-exchange) input via its scheduler.
This is the programmatic entry for the infinite-swapping sampler (the scheduler + config loader), run from the current working directory.
pyretisruncalls it for inputs that select infinite swapping, so it is the single way to drive that sampler.- Parameters:
inputfile (string) – Path to the infinite-swapping input TOML.
- pyretis.bin.pyretisrun.run_infretis_flavour_config(inputfile, runpath)[source]¶
Run a legacy infretis-flavour config via the native-schema pipeline.
Reshapes the raw infretis-flavour dict (
pyretis.inout.config_adapter.normalize_infretis_dialect()), parses the result through the same strict native-schema validator every hand-written native TOML goes through (pyretis.inout.settings.parse_settings_toml()), translates it (pyretis.inout.config_adapter.native_to_infswap_config()), and hands the result to the unchanged scheduler viarun_infinite_swapping()– the same three-stage pipelinerun_pyretis_path_sampling()uses for native input, so both dialects now share one code path from this point on.A restart continuation is excluded from this: it is always invoked by pointing
-idirectly at the scheduler’s ownrestart.toml(never the original config –setup_configitself refuses a fresh input file alongside an existingrestart.toml), andrestart.tomlis already in the coordinator’s own shape, not a user-authored dialect needing translation.- Parameters:
inputfile (string) – Path to the infretis-flavour input TOML.
runpath (string) – The directory the simulation runs from (where the intermediate native-shaped TOML and the final translated
infswap.tomlare written).
- pyretis.bin.pyretisrun.run_md_flux_simulation(sim, sim_settings, progress=False)[source]¶
Run a MD-FLUX simulation.
- Parameters:
sim (object like
Simulation) – This is the simulation to run.sim_settings (dict) – The simulation settings.
progress (boolean, optional) – If True, we will display a progress bar, otherwise, we print results to the screen.
- pyretis.bin.pyretisrun.run_md_simulation(sim, sim_settings, progress=False)[source]¶
Run a MD simulation.
- Parameters:
sim (object like
Simulation) – This is the simulation to run.sim_settings (dict) – The simulation settings.
progress (boolean, optional) – If True, we will display a progress bar, otherwise, we print results to the screen.
- pyretis.bin.pyretisrun.run_pyretis_path_sampling(inputfile, runpath)[source]¶
Run a native RETIS config through the infinite-swapping coordinator.
This is the opt-in compatibility route. It translates the native configuration to the coordinator’s config dictionary (
pyretis.inout.config_adapter.native_to_infswap_config()) and generates the coordinator’sload_dirwhen requested. By default (method = "load", or"kick") this goes through the proven, sequential, single-process native initiation (pyretis.inout.config_adapter.generate_load_dir()), unchanged. Opting into[initial-path] kick-parallel = true(withmethod = "kick"andkick-from = "initial", the default) instead routes through the parallel, engine-agnostic kick phase (pyretis.simulation.setup.run_kick_phase(), one job per ensemble across a worker pool) – proven so far only for engines that drive their kick search throughpropagate()/_propagate_from()(e.g. TurtleMD); internal engines’ ownkick_across_middleis not yet streaming-aware, sokick-parallelstays opt-in rather than the default until that gap is closed. It then writes the resolved config to the singleoutput.tomland hands it to the unchanged scheduler viarun_infinite_swapping().- Parameters:
inputfile (string) – Path to the native RETIS input TOML.
runpath (string) – The directory the simulation runs from (where
loadand the translatedoutput.tomlare written).
- pyretis.bin.pyretisrun.scheduler_supported_features(config)[source]¶
Return
(supported, reason)for routing a native retis config.The infinite-swapping scheduler at
n_workers = 1faithfully reproduces the native RETIS loop for the kick- (or restart-) initialised internal-engine RETIS family with thesh/wt/wf/ssshooting moves (wf/ssvia the WHAMCxy/HAunweighting on the native-output route). Several native features are still scheduler PORT GAPS and must keep the in-process loop until they are ported, so this helper detects them and reports the first one found:shooting moves other than
sh/wt/wf/ss.the permeability
mirror(mirror_freq) andtargetswap (target_freq) moves route through the scheduler but only atn_workers = 1(both persist a global order-function mutation on accept).an
[initial-path] methodofloadfor non-explore tasks.a
[simulation] restartcontinuation.
- Parameters:
config (dict) – The parsed native TOML configuration.
- Returns:
(boolean, string) –
(True, '')when the scheduler faithfully covers the config;(False, reason)naming the first unsupported feature.
- pyretis.bin.pyretisrun.set_up_simulation(inputfile, runpath)[source]¶
Run all the needed generic set-up.
- Parameters:
inputfile (string) – The input file which defines the simulation.
runpath (string) – The base path we are running the simulation from.
- Returns:
runner (method) – A method which can be used to execute the simulation.
sim (object like
Simulation) – The simulation defined by the input file.syst (object like
System) – The system created.sim_settings (dict) – The input settings read from the input file.
- pyretis.bin.pyretisrun.soft_exit_ignore(turn_keyboard_interruption_off=True, exe_dir=None)[source]¶
Manage the KeyboardInterrupt exception.
- Parameters:
turn_keyboard_interruption_off (boolean) – If True, instead of regular exiting from the program, the file ‘EXIT’ is created to stop the PyRETIS.
exe_dir (string, optional) – The path where EXIT file is expected.
- pyretis.bin.pyretisrun.store_simulation_settings(settings, indir, backup, ext='.rst')[source]¶
Store the parsed input settings.
- Parameters:
settings (dict) – The simulation settings.
indir (string) – The directory which contains the input script.
backup (boolean) – If True, an existing settings file will be backed up.
ext (string) – Extension for the regenerated settings dump. Matches the input file extension, so a
.tomlrun writesout.tomland a.rstrun writesout.rst. Defaults to.rstfor backwards compatibility.
pyretis.bin.pyretisclean module¶
pyretisclean - Remove the artifacts of a PyRETIS run.
This is the implementation behind pyretis clean. It deletes the
output a PyRETIS run leaves in a directory (logs, out.toml /
out.rst, restart files, the NNN ensemble directories, report,
byte-code caches, …), so an example or run directory can be reset to its
committed inputs. A per-directory clean.toml extends or overrides the
built-in defaults; see pyretis.inout.clean.
usage: pyretis clean [-h] [–dry-run] [directory]
pyretis.bin.pyretisanalyse module¶
pyretisanalyse - An application for analysing PyRETIS simulations.
This script is a part of the PyRETIS library and can be used for analysing the result from simulations.
usage: pyretisanalyse.py [-h] -i INPUT [-V] [-f LOG_FILE] [-l LOG_LEVEL]
- optional arguments:
- -h, --help
show this help message and exit
- -i INPUT, --input INPUT
Location of PyRETIS input file
- -V, --version
show program’s version number and exit
- -f LOG_FILE, --log_file LOG_FILE
Specify log file to write
- -l LOG_LEVEL, --log_level LOG_LEVEL
Specify log level for log file
- pyretis.bin.pyretisanalyse._countered_report_name(reportfile, report_base, counter)[source]¶
Insert the archive counter before the cycle descriptor.
- pyretis.bin.pyretisanalyse._format_cycle_suffix(cycles)[source]¶
Return a file-name suffix for the number of analysed cycles.
- pyretis.bin.pyretisanalyse._latest_report_pattern(report_base, extension)[source]¶
Return a regexp matching uncountered latest report names.
- pyretis.bin.pyretisanalyse._next_report_counter(path, report_base, extension)[source]¶
Return the next free archive counter for a report family.
- pyretis.bin.pyretisanalyse._path_cycles(result)[source]¶
Return the cycle count from a path-ensemble analysis result.
- pyretis.bin.pyretisanalyse._report_base(report_type, prefix=None)[source]¶
Return the base name for a report without counter or cycles.
- pyretis.bin.pyretisanalyse._report_counter_pattern(report_base, extension)[source]¶
Return a regexp matching countered report archive names.
- pyretis.bin.pyretisanalyse._run_wham_analysis(run_dir, report_dir, nskip=0)[source]¶
Analyse infinite-swapping output (WHAM crossing probability).
- Parameters:
run_dir (string) – The run directory: either a literal
infswap_data.txtlives directly in it, or it holds the numbered native ensemble directories the matrix is reconstructed from – seepyretis.analysis.wham_analysis.get_path_data_matrix().report_dir (string) – Directory the
wham_analysis.txtreport is written to.nskip (int, optional) – Number of initial cycles (records) to discard as equilibration – the
skip_initial_cyclesanalysis setting. Defaults to 0.
- Returns:
int – 0 on success, 1 if the interfaces could not be read.
- pyretis.bin.pyretisanalyse.backup_latest_reports(reportfile, report_base)[source]¶
Back up uncountered reports from a report family.
- pyretis.bin.pyretisanalyse.completed_cycles(analysis_results)[source]¶
Return the number of cycles represented by an analysis result.
- pyretis.bin.pyretisanalyse.configure_file_logging(log_file, log_level)[source]¶
Add the analysis file logger and return the numeric log level.
- pyretis.bin.pyretisanalyse.create_pdf_report(texfile, pdflatex='pdflatex', report_base=None)[source]¶
Compile a LaTeX report to PDF if pdflatex is available.
- pyretis.bin.pyretisanalyse.create_reports(settings, analysis_results, report_path)[source]¶
Create some reports to display the output.
- Parameters:
settings (dict) – Settings for analysis (and the simulation).
analysis_results (dict) – Results from the analysis.
report_path (string) – The path to the directory where the reports should be saved.
- Yields:
out (string) – The report files created.
- pyretis.bin.pyretisanalyse.entry_point()[source]¶
entry_point - The entry point for the pip install of pyretisanalyse.
- pyretis.bin.pyretisanalyse.entry_point_deprecated()[source]¶
Legacy
pyretisanalyseentry: warn, then runpyretis analyse.The standalone
pyretisanalysecommand is kept working for now but is deprecated in favour ofpyretis analyse; from PyRETIS 5 only the unified command will be supported. This wrapper emits that warning and then delegates toentry_point()unchanged.
- pyretis.bin.pyretisanalyse.get_report_name(report_type, ext, prefix=None, path=None, cycles=None, counter=None)[source]¶
Generate file name for a report.
- Parameters:
report_type (string) – Identifier for the report we are writing.
ext (string) – Extension for the file to write.
prefix (string, optional) – A prefix to add to the file name. Usually just used to mark reports with ensemble number for report_type equal to ‘tis-single’
path (string) – A directory to use for saving the report to.
cycles (int, optional) – Number of completed cycles represented by the report.
counter (int, optional) – Archive counter to insert before the cycle descriptor.
- Returns:
out (string) – The name of the file written.
- pyretis.bin.pyretisanalyse.hello_world(infile, run_dir, report_dir, log_file=None)[source]¶
Output a standard greeting for PyRETIS analysis.
- Parameters:
infile (string) – String showing the location of the input file.
run_dir (string) – The location where we are executing the analysis.
report_dir (string) – String showing the location of where we write the output.
log_file (string, optional) – The output log file.
- pyretis.bin.pyretisanalyse.main(input_file, run_path, report_dir)[source]¶
Run the analysis.
- Parameters:
input_file (string) – The input file with settings for the analysis.
run_path (string) – The location from which we are running the analysis.
report_dir (string) – The location where we will write the report.
- pyretis.bin.pyretisanalyse.write_file(outname, report_txt, backup=True, report_base=None)[source]¶
Write a generated report to a given file.
- Parameters:
outname (string) – The name of the file to write/create.
report_txt (string) – This is the generated report as a string.
backup (boolean, optional) – If True, back up an existing report before writing the new one.
report_base (string, optional) – Base report name used to back up the previous uncountered report.
- Returns:
out (string) – The name of the file written.
pyretis.bin.pyvisa module¶
pyvisa - An application for analysing PyRETIS simulations.
This script is a part of the PyRETIS library and can be used for analysing the result from simulations.
Usage:
pyvisa.py [-h] [-i INPUT] [-V] [-cmp] [-data DATA] [-recalculate]
[-oo] [-p] [-w N]
Optional arguments:
-cmp --pyvisa_compressor compress raw simulation output to a .hdf5 file.
-data --pyvisa-data select the data source (file or folder).
-h, --help show this help message and exit.
-i INPUT, --input INPUT location of PyRETIS input files
or PyVisA compressed file.
-oo --only_order use only data from order.txt files (faster).
-p, --progress show progress bars during recalculation.
-recalculate recalculate order parameter and cv data.
-V, --version show program's version number and exit.
-w N, --workers N number of parallel worker processes for
recalculation (default: all CPU cores).
Flags may be combined. Valid combinations include:
pyvisa -i out.rst -cmp # compress only
pyvisa -i out.rst -cmp -oo # compress, order files only
pyvisa -i out.rst -recalculate # recalculate only
pyvisa -i out.rst -recalculate -p # recalculate with progress
pyvisa -i out.rst -recalculate -w 4 # recalculate with 4 workers
pyvisa -i out.rst -recalculate -p -w 4 # recalculate, progress, 4 wk
pyvisa -i out.rst -recalculate -data 000 # recalculate one ensemble
pyvisa -i out.rst -recalculate -cmp # recalculate then compress
pyvisa -i out.rst -recalculate -cmp -oo # recalc then compress (oo)
pyvisa -i out.rst # open GUI
pyvisa -i out.rst -data 000 # open GUI with one ensemble
- pyretis.bin.pyvisa.entry_point()[source]¶
entry_point - The entry point for the pip install of pyretisanalyse.
- pyretis.bin.pyvisa.hello_pyvisa(run_dir, infile)[source]¶
Output a standard greeting for PyVISA.
- Parameters:
run_dir (string) – The location where we are executing the analysis.
infile (string) – String showing the location of the input file.
- pyretis.bin.pyvisa.main(basepath, input_file, pyvisa_dict=None)[source]¶
Run the analysis.
- Parameters:
basepath (string) – The execution folder where the input files are.
input_file (string) – The input file with settings for the analysis.
pyvisa_dict (dictionary, optional) –
It determines the section of pyvisa to use, it contains:
pyvisa_compressor, boolean If true, compress raw output to a .hdf5 file.
pyvisa_data, str If given, the file or folder containing the files that will be used to feed to PyVisA.
pyvisa_recalculate, boolean If true, use the recalculation tool to compute new op and cv values.
only_order, boolean If true, use only data from order.txt files when compressing.
Flags may be combined:
pyvisa_recalculateandpyvisa_compressorcan both be set to run recalculation followed by compression in a single invocation. If neither is set, the visualization GUI is launched.
- pyretis.bin.pyvisa.pyvisa_visual(basepath, input_file, pyvisa_dict)[source]¶
Load data to PyVisA.
- Parameters:
basepath (string) – The execution folder where the input files are.
input_file (string) – The input file with settings for the analysis.
pyvisa_dict (dictionary, optional) – It determines the section of pyvisa to use, it contains: