ADCT Python
Python client API implementation for publishing ADCT data
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
adctk.builder.Header Class Reference

A class to build the header section with the application name given by user and default details. More...

Inheritance diagram for adctk.builder.Header:
Inheritance graph
[legend]
Collaboration diagram for adctk.builder.Header:
Collaboration graph
[legend]

Public Member Functions

 __init__ (self, str application)
 
- Public Member Functions inherited from adctk.builder.Builder
adc_types.Field get_value (self, str path_full)
 get the existing named nested field in the builder.
 
 get_value_string (self, str path)
 get the existing named nested scalar string value.
 
 get_value_int64 (self, str path)
 get the existing named nested scalar int64-equivalent value.
 
 get_value_uint64 (self, str path)
 get the existing named nested scalar uint64-equivalent value.
 
 __json__ (self)
 
 add_header_section (self, str application_name)
 Create or replace the 'header' section using application_name.
 
 add_host_section (self, osinfo=False, ramsize=False, env=False, cpu=False, gpu=False, numa=False, all_hs=False)
 Add the 'host' section, with optional subgroups of properties.
 
 add_app_data_section (self, 'Builder' app_data)
 Create the "app_data" section with data defined by the application writer.
 
 add_model_data_section (self, 'Builder' model_data)
 populate application run-time physics (re)configuration or result to "model_data" section.
 
 add_code_section (self, str tag, 'Builder' version, 'Builder|None' code_details=None)
 Add the 'code' section, with user-specified version subsection and optional code_details section describing things which do not normally vary with invocation.
 
 add_code_configuration_section (self, 'Builder' build_details)
 
 add_exit_data_section (self, 'int|str' return_code, str status, 'Builder|None' status_details=None)
 populate "exit_data" section with return code and status string & user provided details.
 
 add_memory_usage_section (self)
 Populate "memory_usage" section with current host /proc/meminfo data in the style of free(1).
 
'Builder|None' get_section (self, str name)
 get the existing named section.
 
'list[str]' get_section_names (self)
 Get the names of sections.
 
 add_mpi_section (self, name, communicator, bool rank=False, bool size=False, bool mpi_name=False, bool hostlist=False, bool rank_host=False, bool ver=False, bool lib_ver=False, bool mpiall=False, bool local=False)
 Unimplemented: python with mpi is not yet supported.
 
 add_gitlab_ci_section (self)
 Add gitlab_ci environment variable dictionary.
 
 add_workflow_section (self, str|None wfid=None, str|None parent=None, list[str]|str|None children=None)
 add data from adc_wfid_ environment variables.
 
 add_workflow_children (self, collections.abc.Iterable[str] child_uuids)
 Add list of child uuids to "adc_workflow" section after add_workflow_section has been called.
 
 add_slurm_section (self, collections.abc.Iterable[str]|None output_vars=None)
 Add slurm output environment variable dictionary elements.
 
 add_section (self, str name, 'Builder|collections.abc.Mapping[str,...]' section)
 Add or replace a user-defined, named section.
 
str serialize (self)
 get json string of the builder.
 
 add (self, str name, any value, value_type=None)
 add named item and its datatype information to the builder.
 
 add_path (self, name, str path)
 Add string file path.
 
 add_json_string (self, str name, str js)
 Add stringified json.
 
 add_yaml_string (self, str name, str yaml)
 Add stringified yaml.
 
 add_xml_string (self, str name, str xml)
 Add stringified xml.
 
 add_number_string (self, str name, decimal.Decimal dec)
 Add stringified number of arbitrary precision.
 
 add_epoch (self, name, int epoch)
 add unix epoch seconds (gettimeofday)
 
 add_mime (self, str name, str mime_type, str encoding, str file_name, str data)
 add a string encoded object (e.g.
 
 add_array_typed_string (self, name, adc_types.ScalarType st, collections.abc.Iterable[str] strings)
 Add string group tagged with scalar type.
 

Public Attributes

 API_VERSION
 

Additional Inherited Members

- Static Public Member Functions inherited from adctk.builder.Builder
'Builder' BasicBuilder (str app_name)
 DEPRECATED.
 
- Static Public Attributes inherited from adctk.builder.Builder
 API_VERSION = adc_version.AdcVersion()._dict()
 
- Protected Member Functions inherited from adctk.builder.Builder
 _set_attr (self, name, value)
 
 _get_attr (self, name)
 
 _find_path (self, obj, path)
 
dict _flatten (self, depth=0)
 Get a dictionary tree-copy constructed from keys and sections.
 
adc_types.KeyType _kind (self, str name)
 

Detailed Description

A class to build the header section with the application name given by user and default details.

Constructor & Destructor Documentation

◆ __init__()

adctk.builder.Header.__init__ (   self,
str  application 
)

Reimplemented from adctk.builder.Builder.

1212 def __init__(self, application: str):
1213 super().__init__()
1214 self._set_attr("adc_api_version", self.API_VERSION)
1215 y = time.time_ns()
1216 s = y // 1000000000
1217 ns = y % 1000000000
1218 ms = ns // 1000000
1219 self._set_attr("timestamp", f"{s}.{ns}") # "sec.nanosec"
1220 dt = datetime.datetime.fromtimestamp(s)
1221 prefix = dt.strftime("%Y-%m-%dT%H:%M:%S.")
1222 suffix = dt.strftime("%z")
1223 ds = f"{prefix}{ms:03d}{suffix}"
1224 self._set_attr("datestamp", ds) # string 8601 millis, tz
1225 self._set_attr("user", getpass.getuser())
1226 self._set_attr("uid", str(os.getuid()))
1227 self._set_attr("application" , application)
1228 self._set_attr("uuid", str(uuid_compat.UUID7Generator.uuid7()))
1229 # print(f"CTOR:HEADER:{self.serialize()}")

Member Data Documentation

◆ API_VERSION

adctk.builder.Header.API_VERSION

The documentation for this class was generated from the following file: