Automated documentation
- class datarobot.models.automated_documentation.AutomatedDocument
Bases:
APIObject
An automated documentation object.
Added in version v2.24.
- Variables:
document_type (
str
orNone
) – Type of automated document. You can specify:MODEL_COMPLIANCE
,AUTOPILOT_SUMMARY
depending on your account settings. Required for document generation.entity_id (
str
orNone
) – ID of the entity to generate the document for. It can be model ID or project ID. Required for document generation.output_format (
str
orNone
) – Format of the generate document, eitherdocx
orhtml
. Required for document generation.locale (
str
orNone
) – Localization of the document, dependent on your account settings. Default setting isEN_US
.template_id (
str
orNone
) – Template ID to use for the document outline. Defaults to standard DataRobot template. See the documentation forComplianceDocTemplate
for more information.id (
str
orNone
) – ID of the document. Required to download or delete a document.filepath (
str
orNone
) – Path to save a downloaded document to. Either include a file path and name or the file will be saved to the directory from which the script is launched.created_at (
datetime
orNone
) – Document creation timestamp.
- DEFAULT_BATCH_SIZE = 100
- classmethod list_available_document_types(cls)
Get a list of all available document types and locales. This method is deprecated.
- Returns:
{“data”: List of dicts}
- Return type:
List[DocumentOption]
Examples
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) doc_types = dr.AutomatedDocument.list_available_document_types()
- classmethod list_all_available_document_types()
Get a list of all available document types and locales. This method is direct replacement of list_available_document_types().
- Return type:
List
ofdicts
Examples
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) doc_types = dr.AutomatedDocument.list_all_available_document_types()
- property is_model_compliance_initialized: Tuple[bool, str]
Check if model compliance documentation pre-processing is initialized. Model compliance documentation pre-processing must be initialized before generating documentation for a custom model.
- Returns:
boolean flag is whether model compliance documentation pre-processing is initialized
string value is the initialization status
- Return type:
Tuple
of(boolean
,string)
- initialize_model_compliance()
Initialize model compliance documentation pre-processing. Must be called before generating documentation for a custom model.
- Returns:
boolean flag is whether model compliance documentation pre-processing is initialized
string value is the initialization status
- Return type:
Tuple
of(boolean
,string)
Examples
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) # NOTE: entity_id is either a model id or a model package (version) id doc = dr.AutomatedDocument( document_type="MODEL_COMPLIANCE", entity_id="6f50cdb77cc4f8d1560c3ed5", output_format="docx", locale="EN_US") doc.initialize_model_compliance()
- generate(max_wait=600)
Request generation of an automated document.
Required attributes to request document generation:
document_type
,entity_id
, andoutput_format
.- Return type:
requests.models.Response
Examples
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) doc = dr.AutomatedDocument( document_type="MODEL_COMPLIANCE", entity_id="6f50cdb77cc4f8d1560c3ed5", output_format="docx", locale="EN_US", template_id="50efc9db8aff6c81a374aeec", filepath="/Users/username/Documents/example.docx" ) doc.generate() doc.download()
- download()
Download a generated Automated Document. Document ID is required to download a file.
- Return type:
requests.models.Response
Examples
Generating and downloading the generated document:
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) doc = dr.AutomatedDocument( document_type="AUTOPILOT_SUMMARY", entity_id="6050d07d9da9053ebb002ef7", output_format="docx", filepath="/Users/username/Documents/Project_Report_1.docx" ) doc.generate() doc.download()
Downloading an earlier generated document when you know the document ID:
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) doc = dr.AutomatedDocument(id='5e8b6a34d2426053ab9a39ed') doc.download()
Notice that
filepath
was not set for this document. In this case, the file is saved to the directory from which the script was launched.Downloading a document chosen from a list of earlier generated documents:
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) model_id = "6f5ed3de855962e0a72a96fe" docs = dr.AutomatedDocument.list_generated_documents(entity_ids=[model_id]) doc = docs[0] doc.filepath = "/Users/me/Desktop/Recommended_model_doc.docx" doc.download()
- delete()
Delete a document using its ID.
- Return type:
requests.models.Response
Examples
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) doc = dr.AutomatedDocument(id="5e8b6a34d2426053ab9a39ed") doc.delete()
If you don’t know the document ID, you can follow the same workflow to get the ID as in the examples for the
AutomatedDocument.download
method.
- classmethod list_generated_documents(document_types=None, entity_ids=None, output_formats=None, locales=None, offset=None, limit=None)
Get information about all previously generated documents available for your account. The information includes document ID and type, ID of the entity it was generated for, time of creation, and other information.
- Parameters:
document_types (
List
ofstr
orNone
) – Query for one or more document types.entity_ids (
List
ofstr
orNone
) – Query generated documents by one or more entity IDs.output_formats (
List
ofstr
orNone
) – Query for one or more output formats.locales (
List
ofstr
orNone
) – Query generated documents by one or more locales.offset (
int
orNone
) – Number of items to skip. Defaults to 0 if not provided.limit (
int
orNone
) – Number of items to return, maximum number of items is 1000.
- Return type:
List
[AutomatedDocument
]- Returns:
List
ofAutomatedDocument objects
,where each object contains attributes described in
Examples
To get a list of all generated documents:
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) docs = AutomatedDocument.list_generated_documents()
To get a list of all
AUTOPILOT_SUMMARY
documents:import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) docs = AutomatedDocument.list_generated_documents(document_types=["AUTOPILOT_SUMMARY"])
To get a list of 5 recently created automated documents in
html
format:import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) docs = AutomatedDocument.list_generated_documents(output_formats=["html"], limit=5)
To get a list of automated documents created for specific entities (projects or models):
import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) docs = AutomatedDocument.list_generated_documents( entity_ids=["6051d3dbef875eb3be1be036", "6051d3e1fbe65cd7a5f6fde6", "6051d3e7f86c04486c2f9584"] )
Note, that the list of results contains
AutomatedDocument
objects, which means that you can execute class-related methods on them. Here’s how you can list, download, and then delete from the server all automated documents related to a certain entity:import datarobot as dr dr.Client(token=my_token, endpoint=endpoint) ids = ["6051d3dbef875eb3be1be036", "5fe1d3d55cd810ebdb60c517f"] docs = AutomatedDocument.list_generated_documents(entity_ids=ids) for doc in docs: doc.download() doc.delete()