Uploader Expectations and Application Flows¶
This section describes how an end-user of Pacifica Python Uploader is expected to interact with the modules, classes and methods above, and, by extension, Pacifica Ingest and Pacifica Policy servers.
Keywords for the API
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt).
Uploader Program Flow¶
- The uploader program MUST construct a new instance of the
pacifica.uploader.metadata.MetaUpdateclass. The new instance of thepacifica.uploader.metadata.MetaUpdateclass MAY be associated with zero or more of instances of thepacifica.uploader.metadata.MetaObjclass. Thepacifica.uploader.metadata.MetaObj.valuefield MAY beNone. The new instance of thepacifica.uploader.metadata.MetaUpdateclass MUST NOT be associated with any instances of thepacifica.uploader.metadata.FileObjclass. - To determine completeness, the new instance of the
pacifica.uploader.metadata.MetaUpdateclass SHOULD be validated using thepacifica.uploader.metadata.MetaData.is_valid()method (inherited by thepacifica.uploader.metadata.MetaUpdatesub-class). Then, the uploader program MUST call thepacifica.uploader.metadata.PolicyQuery.PolicyQuery.valid_metadata()method. The new instance of thepacifica.uploader.metadata.MetaUpdateclass MUST be valid prior to bundling. - The uploader program MUST dereference the
pacifica.uploader.metadata.MetaObj.displayTypefield to determine the mode of selection for thepacifica.uploader.metadata.MetaObj.valuefield. The value of thepacifica.uploader.metadata.MetaObj.displayTypefield is uploader-program-specific, i.e., the value MUST be defined by the uploader program. - The uploader program MUST assign a non-
Nonevalue to eachpacifica.uploader.metadata.MetaData.query_resultsfield by calling thepacifica.uploader.metadata.MetaUpdate.query_results()method. Thepacifica.uploader.metadata.MetaData.query_resultsfield is alist. - The value of the
pacifica.uploader.metadata.MetaData.query_resultsfield MUST be rendered according to the uploader-program-specific definition that is interpreted from the value of thepacifica.uploader.metadata.MetaObj.displayFormatfield, e.g., in the Python programming language, by calling thestr.formatmethod or by leveraging a template engine, such as Cheetah or Jinja2. - The uploader program MAY call the
pacifica.uploader.metadata.MetaUpdate.query_results()method for instances of thepacifica.uploader.metadata.MetaObjclass whosevaluefield is non-None. - The uploader program MUST handle all instances
pacifica.uploader.metadata.MetaUpdateclass, regardless of validity, i.e., the uploader program MUST NOT reject an instance of thepacifica.uploader.metadata.MetaUpdateclass under any circumstances, e.g., if there are unsatisfied dependencies between instances of thepacifica.uploader.metadata.MetaDataclass. - When the uploader program is ready for a given
pacifica.uploader.metadata.MetaObj.valuefield to be selected, the uploader program MUST assign to thepacifica.uploader.metadata.MetaObj.valuefield the value of thepacifica.uploader.metadata.MetaObj.valueFieldfield, and then call thepacifica.uploader.metadata.MetaObj.update_parents()method. The effect of this operation is to update thepacifica.uploader.metadata.MetaObj.valuefields of associated and dependent instances of thepacifica.uploader.metadata.MetaObjclass. After modification, the new state of the instance of thepacifica.uploader.metadata.MetaUpdate.MetaUpdateclass SHOULD be displayed to the end-user, as previously discussed. - The uploader program MUST verify that
pacifica.uploader.metadata.MetaUpdate.MetaUpdate.is_valid() == True. If the instance of thepacifica.uploader.metadata.MetaUpdate.MetaUpdateclass is not valid, then the uploader program MUST repeat the instructions in the paragraph 8. - The uploader program MUST call the
pacifica.uploader.metadata.PolicyQuery.PolicyQueryData.valid_metadata()method to validate the instance of thepacifica.uploader.metadata.MetaUpdate.MetaUpdateclass prior to upload. This prevents the uploader program from uploading metadata that is invalid with respect to the policy of the Pacifica Ingest server. - When the uploader program is ready to bundle the data, the uploader program
MUST construct a
listof objects, representing the fields of the corresponding instance of thetar.TarInfoclass. Each object MUST export afileobjfield whose value implements the file protocol, i.e., exports aread()method. - The uploader program MUST construct a new instance of the
pacifica.uploader.bundler.Bundlerclass using the instances of thepacifica.uploader.metadata.MetaUpdate.MetaUpdateandtar.TarInfoclasses, as previously stated in paragraph 11. Then, the uploader program MUST construct a file-like object that can be written to in binary mode, and then call thepacifica.uploader.bundler.Bundler.stream()method. - The uploader program MUST construct a new instance of the
pacifica.uploader.Uploader.Uploaderclass. Then, the uploader program MUST construct a file-like object that can be read in binary mode, and then call thepacifica.uploader.bundler.Bundler.upload()method. - Finally, the uploader program MUST verify the result of the ingest by
calling the
pacifica.uploader.Uploader.Uploader.getstate()method. If an ingest-related error occurs, then the uploader program MAY repeat the ingest operation.