Hi Austin,
Thank you very much for response, I tried by compressing the file and it is working fine. I am now trying to call the modelmanager validate method or Validate class validate method using a simple python script but getting below error. The same xbrl file when I try using the command line and calling rest api I am getting success response. please review the script and let me know if I have missed anything and is it possible to call validate method like this from python script.
Sample Python Script:
import sys
import arelle.Cntlr
def validate_xbrl(xbrl_file):
"""
Validate an XBRL instance file using Arelle.
Args:
xbrl_file (str): Path to the XBRL instance document to be validated.
Returns:
bool: True if the document is valid, False otherwise.
"""
# Initialize Arelle controller
controller = arelle.Cntlr.Cntlr(logFileName="logToBuffer")
try:
# Access the ModelManager
modelManager = controller.modelManager
#formula_options = modelManager.FormulaOptions
# If needed, customize the formulaOptions, though the default settings might suffice
#formula_options.validationMode = 'full' # Possible values: 'full', 'quick'
#formula_options.debug = False # Set to True for debug information
#formula_options.reportError = True # Report errors during formula validation
# Load the XBRL file using Arelle's modelManager
model_xbrl = modelManager.load(xbrl_file)
if not model_xbrl:
print(f"Error loading XBRL file: {xbrl_file}")
return False
# Perform validation using the modelManager's validate function
modelManager.validate()
log = controller.logHandler.getText()
print(log)
# Check if there are any validation errors
if model_xbrl.errors:
print(f"Validation failed with {len(model_xbrl.errors)} error(s):")
for error in model_xbrl.errors:
print(error)
return False
else:
print("XBRL document is valid!")
return True
except Exception as e:
print(f"An error occurred: {e}")
return False
finally:
controller.close()
# Main entry point for script execution
if __name__ == "__main__":
# Replace this path with the actual XBRL file you want to validate
xbrl_file_path = "C:\\irr3\\IRRQ3_XBRL.xbrl"
if validate_xbrl(xbrl_file_path):
print("XBRL file validation passed!")
else:
print("XBRL file validation failed!")
end of python script
Arelle Version: 2.36.9
Python Version: 3.12.5
Error:
C:\Users\DEPGOP\AppData\Roaming\Python\Python312\Scripts>python arelle4.py
2025-02-07 08:50:01,419 [exception:AttributeError] Instance validation exception: 'ModelManager' object has no attribute 'formulaOptions', instance: IRRQ3_XBRL.xbrl - IRRQ3_XBRL.xbrl
Traceback (most recent call last):
File "C:\Users\DEPGOP\AppData\Roaming\Python\Python312\site-packages\arelle\Validate.py", line 131, in validate
self.instValidator.validate(self.modelXbrl, self.modelXbrl.modelManager.formulaOptions.typedParameters(self.modelXbrl.prefixedNamespaces))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ModelManager' object has no attribute 'formulaOptions'
Validation failed with 1 error(s):
exception:AttributeError
XBRL file validation failed!
so, I uncommented the formula options and tried, but getting the below error.
Error:
C:\Users\DEPGOP\AppData\Roaming\Python\Python312\Scripts>python arelle4.py
An error occurred: 'ModelManager' object has no attribute 'formulaOptions'
XBRL file validation failed!
same xbrl file when executed from command line:
C:\Users\DEPGOP\AppData\Roaming\Python\Python312\Scripts>arelleCmdLine.exe --file C:\\irr3\\IRRQ3_XBRL.xbrl --validate
[info] loaded in 1.03 secs at 2025-02-07T08:57:09 - C:\\irr3\\IRRQ3_XBRL.xbrl
[info] validated in 0.07 secs - C:\\irr3\\IRRQ3_XBRL.xbrl
same xbrl file when compressed and invoked python rest api:
<?xml version="1.0" encoding="utf-8"?>
<log>
<entry code="info" level="info">
<message>2025-02-07 08:58:46,554 [info] loaded in 0.95 secs at 2025-02-07T08:58:45 - \POSTupload.zip\data
</message>
<ref href="\POSTupload.zip\data"/>
</entry>
<entry code="info" level="info">
<message>2025-02-07 08:58:46,634 [info] validated in 0.08 secs - \POSTupload.zip\data
</message>
<ref href="\POSTupload.zip\data"/>
</entry>
</log>
Thanks & Regards
Depak