asyncmd.tools

asyncmd.tools#

This file contains functions and classes (re)used internally in asyncmd.

These functions and classes are not (thought to be) exposed to the users but instead intended to be (re)used in newly added asyncmd code. This is also not the place for MD-related utility functions, for this see utils.py

Currently in here are:

  • ensure_executable_available

  • remove_file_if_exist and remove_file_if_exist_async

  • attach_kwargs_to_object: a function to attach kwargs to an object as properties or attributes. This does type checking and warns when previously unset things are set. It is used, e.g., in the GmxEngine and SlurmProcess classes.

  • DescriptorWithDefaultOnInstanceAndClass and DescriptorOutputTrajType: two descriptor classes to make default values accessible on the class level but still enable checks when setting on the instance level (like a property), used in the GmxEngine classes but could/should be useful for any MDEngine class

  • FlagChangeList (and its typed sibling): lists with some sugar to remember if their content has changed

Functions

attach_kwargs_to_object(obj, *, logger, **kwargs)

Set all kwargs as object attributes/properties, error on mismatching type.

ensure_executable_available(executable)

Ensure the given executable is available and executable.

remove_file_if_exist(f)

Remove a given file if it exists.

remove_file_if_exist_async(f)

Remove a given file if it exists asynchronously.

Classes

DescriptorOutputTrajType()

Check the value given is in the set of allowed values before setting.

DescriptorWithDefaultOnInstanceAndClass()

A descriptor that makes the (default) value of the private attribute _name of the class it is attached to accessible as name on both the class and the instance level.

FlagChangeList(data)

A list that knows if it has been changed after initializing.

TypedFlagChangeList(data, dtype)

A FlagChangeList with an ensured type for individual list items.