ecsjobs.config module

class ecsjobs.config.Config[source]

Bases: object

YAML_EXTNS = ['.yml', '.yaml']

File extensions to consider as YAML config files.

_get_multipart_config(bucket, prefix)[source]

Retrieve each piece of a multipart config from S3; return the combined configuration (i.e. the corresponding single-dict config).

Parameters:
  • bucket (S3.Bucket) – the S3 bucket to retrieve configs from
  • prefix (str) – prefix for configuration files
Returns:

combined configuration dict

Return type:

dict

_get_yaml_from_s3(bucket, key)[source]

Retrieve the contents of a file from S3 and deserialize the YAML.

Parameters:
  • bucket (S3.Bucket) – the S3 bucket to retrieve the file from
  • key (str) – key/path of the file
Returns:

deserialized YAML file contents

Return type:

dict

_global_defaults = {'email_subject': 'ECSJobs Report', 'failure_command': None, 'failure_html_path': None, 'inter_poll_sleep_sec': 10, 'max_total_runtime_sec': 3600}

Default values for global configuration settings.

_key_is_yaml(key)[source]

Test whether or not the specified S3 key is a YAML file.

Parameters:key (str) – key in S3
Returns:whether key is a YAML file
Return type:bool
_load_config()[source]

Check environment variables; call either _load_config_s3() or _load_config_local().

Raises:RuntimeError
_load_config_local(conf_path)[source]

Load configuration from the local filesystem. Sets self._raw_conf.

Parameters:conf_path (str) – path to configuration on local FS
_load_config_s3(bucket_name, key_name)[source]

Retrieve and load configuration from S3. Sets self._raw_conf.

Parameters:
  • bucket_name (str) – Name of the S3 bucket to retrieve config from
  • key_name (str) – config key or prefix in bucket
_load_yaml_from_disk(path)[source]

Load a YAML file from disk and return the contents.

Parameters:path (str) – path to load from
Returns:deserialized YAML file contents
Return type:dict
_make_jobs()[source]

Reads self._jobs_conf and instantiates job classes, populating self._jobs.

_validate_config()[source]

Validate the configuration in self._raw_conf. Writes self._global_conf.

get_global(k)[source]

Return the value of the specified global configuration setting, from the global configuration (if present) or else from the global defaults.

Parameters:k – configuration key to get
Returns:value of global config setting
jobs

Return the list of ecsjobs.jobs.base.Job instances.

Returns:list of jobs
Return type:list
jobs_for_schedules(schedule_names)[source]

Given one or more schedule names, return the list of jobs for those schedules (in order).

Parameters:schedule_names (list) – schedule names to get jobs for
Returns:list of Jobs for the specified schedules
Return type:list
schedule_names

Return a list of all String schedule names defined in the config.

Returns:all defined schedule names
Return type:list