I've an error 500 that I don't understand. The error was here before I begin to work on this project so it's complicated. When I click on button to open a PDF (with html2pdf), the error 500 appear. I've tried all I've found, but nothings works.
I can't send you code, or maybe few lines.
Output from error log:
2017-07-03 14:04:28 Error: Fatal Error (1): Maximum execution time of
60 seconds exceeded in [C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Error\BaseErrorHandler.php,
line 126] Request URL: /fra/my-leads/view/aekt.pdf Referer URL:
http://localhost:8765/fra/my-leads Trace:
Cake\Error\BaseErrorHandler::handleFatalError() -
CORE\src\Error\BaseErrorHandler.php, line 223
Cake\Error\BaseErrorHandler::Cake\Error{closure}() -
CORE\src\Error\BaseErrorHandler.php, line 105 [main] - [internal],
line ??
2017-07-03 14:04:28 Error: [Cake\Error\FatalErrorException] Maximum
execution time of 60 seconds exceeded Request URL:
/fra/my-leads/view/aekt.pdf Referer URL:
http://localhost:8765/fra/my-leads Stack Trace: 0 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Error\BaseErrorHandler.php(105):
Cake\Error\BaseErrorHandler->handleFatalError(1, 'Maximum executi...',
'C:\Users\JCP 2...', 126) 1 [internal function]:
Cake\Error\BaseErrorHandler->Cake\Error{closure}() 2 {main}
More precision : when I just write "hello" in pdf, I don't have error. It's only when I try to get datas. And when I set this pdf to another view (so without pdf format) it works :/
Log output after increasing execution time
2017-07-04 08:19:08 Error: [Spipu\Html2Pdf\Exception\ImageException]
Unable to get the size of the image
[http://localhost:8765/img/logo.png?1497859287] Request URL:
/fra/my-leads/view/trkkdz.pdf Referer URL:
http://localhost:8765/fra/my-leads
I try to comment the logo and now, it says this :
2017-07-04 08:23:06 Error: [Exception] TCPDF ERROR: Some data has
already been output, can't send PDF file Request URL:
/fra/my-leads/view/trkkdz.pdf Referer URL: ... Stack Trace: 0
C:\Users\JCP
2\Documents\buyers\vendor\tecnickcom\tcpdf\tcpdf.php(7620):
TCPDF->Error('Some data has a...') 1 C:\Users\JCP
2\Documents\buyers\vendor\spipu\html2pdf\src\Html2Pdf.php(506):
TCPDF->Output('MLC_Lead-trkkdz...', 'I') 2 C:\Users\JCP
2\Documents\buyers\src\Template\Layout\pdf\default.ctp(10):
Spipu\Html2Pdf\Html2Pdf->output('MLC_Lead-trkkdz...') 3 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\View\View.php(1010):
include('C:\Users\JCP 2...') 4 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\View\View.php(971):
Cake\View\View->_evaluate('C:\Users\JCP 2...', Array) 5 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\View\View.php(642):
Cake\View\View->_render('C:\Users\JCP 2...') 6 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\View\View.php(600):
Cake\View\View->renderLayout('', 'default') 7 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Controller\Controller.php(623):
Cake\View\View->render(NULL, NULL) 8 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php(125):
Cake\Controller\Controller->render() 9 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php(93):
Cake\Http\ActionDispatcher->_invoke(Object(App\Controller\MyLeadsController))
10 C:\Users\JCP
2\Documents\buyers\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(60):
Cake\Http\ActionDispatcher->dispatch(Object(Cake\Http\ServerRequest),
Object(Cake\Http\Response)) 11 C:\Users\JCP
2\Documents\buyers\webroot\index.php(37):
Cake\Routing\Dispatcher->dispatch(Object(Cake\Http\ServerRequest),
Object(Cake\Http\Response)) 12 {main}
This means your application is taking more than 60 seconds to run. That is why it is crushing. Add the code below to index.php in webroot directory
<?php
set_time_limit ( 60 * 5 ); // 5 minutes
?>
or in your php.ini :
max_execution_time=300
Related
JSONDecodeError at /profile
Expecting value: line 1 column 1 (char 0)
Request Method: POST
Request URL: http://127.0.0.1:8000/profile
Django Version: 3.2.6
Exception Type: JSONDecodeError
Exception Value:
Expecting value: line 1 column 1 (char 0)
Exception Location: C:\Users\bismi\AppData\Local\Programs\Python\Python310\lib\json\decoder.py, line 355, in raw_decode
Python Executable: C:\Users\bismi\AppData\Local\Programs\Python\Python310\python.exe
Python Version: 3.10.6
Python Path:
['C:\Users\bismi\OneDrive\Desktop\connectyfi modftn\connectyfi',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310\python310.zip',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310\DLLs',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310\lib',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310',
'C:\Users\bismi\AppData\Local\Programs\Python\Python310\lib\site-packages']
I tried to use the dataset API loaded with my own data to train the hunggingface model.
This is my code:
train_data= datasets.load_dataset('csv', data_files="/gdrive/MyDrive/project/train.csv")
test_data= datasets.load_dataset('csv', data_files="/gdrive/MyDrive/project/test.csv")
train_data
DatasetDict({
train: Dataset({
features: ['Post', 'Label'],
num_rows: 174
})
})
But in the trainer, I get this error message. What happens to my dataset. I do not find any error. Could you help me? Thank you!
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_data,
eval_dataset=test_data
)
trainer.train()
KeyError Traceback (most recent call last)
<ipython-input-63-3435b262f1ae> in <module>()
----> 1 trainer.train()
5 frames
/usr/local/lib/python3.7/dist-packages/datasets/dataset_dict.py in __getitem__(self, k)
44 suggested_split = available_suggested_splits[0] if available_suggested_splits else list(self)[0]
45 raise KeyError(
---> 46 f"Invalid key: {k}. Please first select a split. For example: "
47 f"`my_dataset_dictionary['{suggested_split}'][{k}]`. "
48 f"Available splits: {sorted(self)}"
KeyError: "Invalid key: 0. Please first select a split. For example: `my_dataset_dictionary['train'][0]`. Available splits: ['train']"
I'm using dropzone to send files to a springboot api, which processes those files and returns a pdf response, which I want to display on my angular front-end. Everything works fine until time to display the pdf, when it renders a blank pdf (with the correct number of pages) along with the warnings in console:
Warning: Indexing all PDF objects pdf.worker.min.js:1
Warning: Invalid stream: "FormatError: Bad FCHECK in flate stream: 120, 239"
I know that the pdf itself is not corrupt, because when I make a get request to the API to retrieve the stored version of the same pdf, it is not corrupt and renders fine.
I have tried using TextEncoder:
let enc = new TextEncoder();
this.masterPdf = enc.encode(event[1])
using FileReader:
var reader = new FileReader();
reader.onload = function() {
var arrayBuffer = this.result;
self.masterPdf = new Uint8Array(arrayBuffer);
console.log(self.masterPdf);
self.masterShow = true;
}
var blob = new Blob([event[1]], {type:'application/pdf'});
reader.readAsArrayBuffer(blob);
and using StringToBytes:
let strToByteArr = stringToBytes(event[1]);
this.masterPdf = new Uint8Array(strToByteArr);
event in all of these cases is the response, here it is below (of course the pdf string is actually much longer):
0: File(1237) {upload: {…}, status: "success", accepted: true, processing: true, xhr: XMLHttpRequest, …}
1:"%PDF-1.7↵%����↵1 0 obj↵<</Type/Catalog/Pages 2 0 R/Lang(en-US) /StructTreeRoot 12 0 R/MarkInfo<</Marked true>>/Metadata 32 0 R/ViewerPreferences 33 0 R>>↵endobj↵2 0 obj↵<</Type/Pages/Count 2/Kids[ 3 0 R 9 0 R] >>↵endobj↵3 0 obj↵<</Type/Page/Parent 2 0 R/Resources<</Font<</F1 5 0 R>>/ExtGState<</GS7 7 0 R/GS8 8 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 612 792] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S/StructParents 0>>↵endobj↵4 0 obj↵<</Filter/FlateDecode/Length 3808>>↵stream
2: ProgressEvent {isTrusted: true, lengthComputable: true, loaded: 99282, total: 99282, type: "load", …}
I did check those particular bytes (120-239) in the valid file returned versus the invalid one, and they are different, but the invalid one just looked like normal numbers.
When requesting a PDF from an API, set the request's response type to 'blob'. The default type is application/json.
Once the file has been received, create a blob using the response's data then use the blob to create a url.
let blob = new Blob([data], {type: 'application/pdf'})
let url = window.URL.createObjectURL(blob)
Call to get_execution_role() from notebook instance fails with the error message NoSuchEntityException: An error occurred (NoSuchEntity) when calling the GetRole operation: The user with name <name> cannot be found.
Stack trace:
NoSuchEntityExceptionTraceback (most recent call last)
<ipython-input-1-1e2d3f162cfe> in <module>()
5 sagemaker_session = sagemaker.Session()
6
----> 7 role = get_execution_role()
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/sagemaker/session.pyc in get_execution_role(sagemaker_session)
871 if not sagemaker_session:
872 sagemaker_session = Session()
--> 873 arn = sagemaker_session.get_caller_identity_arn()
874
875 if 'role' in arn:
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/sagemaker/session.pyc in get_caller_identity_arn(self)
701 # Call IAM to get the role's path
702 role_name = role[role.rfind('/') + 1:]
--> 703 role = self.boto_session.client('iam').get_role(RoleName=role_name)['Role']['Arn']
704
705 return role
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/botocore/client.pyc in _api_call(self, *args, **kwargs)
312 "%s() only accepts keyword arguments." % py_operation_name)
313 # The "self" in this scope is referring to the BaseClient.
--> 314 return self._make_api_call(operation_name, kwargs)
315
316 _api_call.__name__ = str(py_operation_name)
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/botocore/client.pyc in _make_api_call(self, operation_name, api_params)
610 error_code = parsed_response.get("Error", {}).get("Code")
611 error_class = self.exceptions.from_code(error_code)
--> 612 raise error_class(parsed_response, operation_name)
613 else:
614 return parsed_response
NoSuchEntityException: An error occurred (NoSuchEntity) when calling the GetRole operation: The user with name <name> cannot be found.
However using boto client directly to get info about the role succeeds. This works fine:
response = client.get_role(
RoleName='role-name',
)['Role']['Arn']
Turns out this is some weird bug that goes away if you stop and start the notebook instance.
I have shutdown and run again the notebook and it works.
PD: I have to run again the code to make effect.
I have a lot of warning when trying to run Selenium2 tests through codeception. The tests work though.
These are the warning if someone can lead me on the right way to correct :
C:\Users\Bebop\Documents\Site Internet\Sites\prestashop1.5.6\modules\paypal>php
codecept.phar run Selenium
Codeception PHP Testing Framework v1.7.0.2
Powered by PHPUnit 3.7.27 by Sebastian Bergmann.
PHP Warning: array_merge(): Argument #2 is not an array in phar://C:/Users/Bebo
p/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/src
/Codeception/Module/Selenium2.php on line 70
PHP Stack trace:
PHP 1. {main}() C:\Users\Bebop\Documents\Site Internet\Sites\prestashop1.5.6\m
odules\paypal\codecept.phar:0
PHP 2. require_once() C:\Users\Bebop\Documents\Site Internet\Sites\prestashop1
.5.6\modules\paypal\codecept.phar:7
PHP 3. Symfony\Component\Console\Application->run() phar://C:/Users/Bebop/Docu
ments/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/codecept:
29
PHP 4. Symfony\Component\Console\Application->doRun() phar://C:/Users/Bebop/Do
cuments/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/vendor/
symfony/console/Symfony/Component/Console/Application.php:121
PHP 5. Symfony\Component\Console\Application->doRunCommand() phar://C:/Users/B
ebop/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/
vendor/symfony/console/Symfony/Component/Console/Application.php:191
PHP 6. Symfony\Component\Console\Command\Command->run() phar://C:/Users/Bebop/
Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/vendo
r/symfony/console/Symfony/Component/Console/Application.php:897
PHP 7. Codeception\Command\Run->execute() phar://C:/Users/Bebop/Documents/Site
Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/vendor/symfony/cons
ole/Symfony/Component/Console/Command/Command.php:244
PHP 8. Codeception\Command\Run->runSuites() phar://C:/Users/Bebop/Documents/Si
te Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/src/Codeception/C
ommand/Run.php:83
PHP 9. Codeception\Codecept->runSuite() phar://C:/Users/Bebop/Documents/Site I
nternet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/src/Codeception/Comma
nd/Run.php:115
PHP 10. Codeception\SuiteManager->__construct() phar://C:/Users/Bebop/Documents
/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/src/Codeceptio
n/Codecept.php:124
PHP 11. Codeception\SuiteManager->initializeModules() phar://C:/Users/Bebop/Doc
uments/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/src/Code
ception/SuiteManager.php:48
PHP 12. Codeception\Module\Selenium2->_initialize() phar://C:/Users/Bebop/Docum
ents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/src/Codece
ption/SuiteManager.php:62
PHP 13. array_merge() phar://C:/Users/Bebop/Documents/Site Internet/Sites/prest
ashop1.5.6/modules/paypal/codecept.phar/src/Codeception/Module/Selenium2.php:70
Warning: array_merge(): Argument #2 is not an array in phar://C:/Users/Bebop/Doc
uments/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/src/Code
ception/Module/Selenium2.php on line 70
Call Stack:
0.0117 1074720 1. {main}() C:\Users\Bebop\Documents\Site Internet\Sites
\prestashop1.5.6\modules\paypal\codecept.phar:0
0.0208 1373568 2. require_once('phar://C:/Users/Bebop/Documents/Site In
ternet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/codecept') C:\Users\Be
bop\Documents\Site Internet\Sites\prestashop1.5.6\modules\paypal\codecept.phar:7
0.0667 4331624 3. Symfony\Component\Console\Application->run() phar://C
:/Users/Bebop/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codec
ept.phar/codecept:29
0.0785 4941624 4. Symfony\Component\Console\Application->doRun() phar:/
/C:/Users/Bebop/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/cod
ecept.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:121
0.0791 4941624 5. Symfony\Component\Console\Application->doRunCommand()
phar://C:/Users/Bebop/Documents/Site Internet/Sites/prestashop1.5.6/modules/pay
pal/codecept.phar/vendor/symfony/console/Symfony/Component/Console/Application.p
hp:191
0.0792 4941624 6. Symfony\Component\Console\Command\Command->run() phar
://C:/Users/Bebop/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/c
odecept.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:89
7
0.0802 4941992 7. Codeception\Command\Run->execute() phar://C:/Users/Be
bop/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/v
endor/symfony/console/Symfony/Component/Console/Command/Command.php:244
0.1596 9010384 8. Codeception\Command\Run->runSuites() phar://C:/Users/
Bebop/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar
/src/Codeception/Command/Run.php:83
0.1597 9010720 9. Codeception\Codecept->runSuite() phar://C:/Users/Bebo
p/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/src
/Codeception/Command/Run.php:115
0.1675 9175200 10. Codeception\SuiteManager->__construct() phar://C:/Use
rs/Bebop/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codecept.p
har/src/Codeception/Codecept.php:124
0.1756 10263064 11. Codeception\SuiteManager->initializeModules() phar://
C:/Users/Bebop/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/code
cept.phar/src/Codeception/SuiteManager.php:48
0.1867 11096264 12. Codeception\Module\Selenium2->_initialize() phar://C:
/Users/Bebop/Documents/Site Internet/Sites/prestashop1.5.6/modules/paypal/codece
pt.phar/src/Codeception/SuiteManager.php:62
0.1914 11529024 13. array_merge() phar://C:/Users/Bebop/Documents/Site In
ternet/Sites/prestashop1.5.6/modules/paypal/codecept.phar/src/Codeception/Module
/Selenium2.php:70
============= At this time the tests begins
←[1mSelenium Tests (1) ←[0m-----------------------------------------------------
--------------
Trying to ←[35;1mlogin in backoffice←[0m (PrestaShopModuleListCest.install_the_m
odule) Ok
--------------------------------------------------------------------------------
-------
Time: 27.79 seconds, Memory: 16.25Mb
←[30;42m←[2KOK (1 test, 0 assertions)
←[0m←[2K
Ok, Found out what was wrong :
I had a missing space in my Selenium.suite.yml which did not convert my capabilities in an array :
capabilities:
unexpectedAlertBehaviour: 'accept'
This was the good thing to do