schrodinger.utils.featureflags.featureflags module

schrodinger.utils.featureflags.featureflags.get_features() Tuple[Set[str], Set[str], Dict[str, Dict[str, str]]]

Get the feature flags from site and user state files. If SCHRODINGER_FEATURE_FLAGS is set, its values are included with the user state.

Returns

sets of feature flag names from site and user state file, and combined_flags as a dict of of feature flag name and additional attributes as dict. The final state of the feature flag and source used to decide would be evaluated by the caller.

schrodinger.utils.featureflags.featureflags.set_features(features, desired_state)

Enable or Disable the given features.

This also report the given features which are not present in the default state file.

Parameters

features (list or set) – List of features to enable or disable in the user state file.

Returntype

tuple(int, features)

Returns

(number of features changed, list of unknown features)

Raises

ValueError – if json document cannot be parsed.

schrodinger.utils.featureflags.featureflags.get_state_string(state)

Convert the feature state from integer to a string.

Parameters

state (int) – Feature state in integer format.

Returntype

string

Returns

0 => Disabled, 1 => Enabled, -1 => None

schrodinger.utils.featureflags.featureflags.get_env_var_warning()
Returns

If there are conflicting env var settings, return a string with the description. Otherwise, return None.

Rtype str or None

schrodinger.utils.featureflags.featureflags.env_var_feature_flag_is_set()

Return boolean whether SCHRODINGER_FEATURE_FLAGS is set or not

schrodinger.utils.featureflags.featureflags.site_state_is_hidden() bool

Return whether the environment points to hiding the site state file.

schrodinger.utils.featureflags.featureflags.list_features(search='*')

Show all available features based on accessibility from site state file or user state file + flags specified with SCHRODINGER_FEATURE_FLAGS when search string is not specified. If search string is given, feature matching the search string will be shown. Otherwise feature whose description match the search string is shown only when state file is accessible.

The function will list the output in following format:

<feature_name> : <Enabled|Disabled>
    <Description if available>
    <User State>    : <Enabled|Disabled|None>
    <Default State> : <Enabled|Disabled>
Parameters

search_string (str) – Optional search string.

schrodinger.utils.featureflags.featureflags.get_nondefault_features() str

Return a string usable as the SCHRODINGER_FEATURE_FLAGS environment variable that includes any non-default settings in either the user settings or site settings, and any user settings that restore non-default site settings to their defaults.

Returns “0” if there are no non-default settings.

schrodinger.utils.featureflags.featureflags.get_site_nondefaults() Set[str]

Return the nondefault feature flags in the site state file.

schrodinger.utils.featureflags.featureflags.get_user_feature_env(feature_const: int, enable: bool = True)

Enable a feature flag and return dict with custom feature flags.

Parameters
  • feature_const (int) – Feature to be enabled/disabled

  • enable (bool) – If True enable, if False disable

Raises

ValueError – If feature is unknown

Return type

dict

Returns

Dict with key SCHRODINGER_FEATURE_FLAGS and all the custom flags as value

schrodinger.utils.featureflags.featureflags.parse_args(argv=None)

Setup code for argument parsing

Params argv

Arguments to parse.

schrodinger.utils.featureflags.featureflags.get_fflags_env_to_export(enable_flags: Set[str], disable_flags: Set[str], unknown_flags: List[str]) str

Returns a new value for SCHRODINGER_FEATURE_FLAGS that needs to be exported to pick up changes in the feature flags provided in the enable or disable arguments.

If the environment variable is not already set or there is no modification required, this returns None.

NOTE:
  1. We don’t clean the existing environment value and just extend the flags to enable or disable. So, if something is newly enabled, but disabled in the environment variable it will result in something like -FEATURE+FEATURE, which evaluates as enabled.

  2. If SCHRODINGER_FEATURE_FLAGS is set to 0 to ignore initially, we assume the value needs to be modified to accept user’s request to enable or disable feature flag.

Parameters
  • enable_flags – feature flags to enable.

  • disable_flags – feature flags to disable.

  • unknown_flags – unknown feature flags categorized from enable_flags or disable_flags identified from user’s request to enable or disable.

Returns

new value to export for SCHRODINGER_FEATURE_FLAGS or None.

schrodinger.utils.featureflags.featureflags.main(argv=None)