Installation does not work

Ubuntu 18.04
NodeJS: 8.11.3
Npm: 5.6.0
Installed serverless globally first.
Install serverless-artillery (as root) I keep getting this:
root:~# npm install -g serverless-artillery
npm WARN deprecated<EMAIL_ADDRESS>This package has been renamed to 'driftless'. Please see https://www.npmjs.com/package/driftless for more information.
npm WARN deprecated<EMAIL_ADDRESS>ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated<EMAIL_ADDRESS>Use uuid module instead
/usr/bin/serverless-artillery -> /usr/lib/node_modules/serverless-artillery/bin/serverless-artillery
/usr/bin/slsart -> /usr/lib/node_modules/serverless-artillery/bin/serverless-artillery

><EMAIL_ADDRESS>postinstall /usr/lib/node_modules/serverless-artillery
> node ./postinstall.js

npm ERR! path /root/.npm/_logs
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall scandir
npm ERR! Error: EACCES: permission denied, scandir '/root/.npm/_logs'
npm ERR!  { Error: EACCES: permission denied, scandir '/root/.npm/_logs'
npm ERR!   stack: 'Error: EACCES: permission denied, scandir \'/root/.npm/_logs\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'scandir',
npm ERR!   path: '/root/.npm/_logs' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
glob error { Error: EACCES: permission denied, scandir '/root/.npm/_logs'
  stack: 'Error: EACCES: permission denied, scandir \'/root/.npm/_logs\'',
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/root/.npm/_logs' }
npm ERR! path /root/.npm/_cacache/index-v5/e5/fa/acf6567ed8f4d89f375a561204919e71d6a6c0e7873e3fbb35148e93c04c
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open '/root/.npm/_cacache/index-v5/e5/fa/acf6567ed8f4d89f375a561204919e71d6a6c0e7873e3fbb35148e93c04c'
npm ERR!  { Error: EACCES: permission denied, open '/root/.npm/_cacache/index-v5/e5/fa/acf6567ed8f4d89f375a561204919e71d6a6c0e7873e3fbb35148e93c04c'
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, open '/root/.npm/_cacache/index-v5/e5/fa/acf6567ed8f4d89f375a561204919e71d6a6c0e7873e3fbb35148e93c04c'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'open',
npm ERR!      path: '/root/.npm/_cacache/index-v5/e5/fa/acf6567ed8f4d89f375a561204919e71d6a6c0e7873e3fbb35148e93c04c' },
npm ERR!   isOperational: true,
npm ERR!   stack: 'Error: EACCES: permission denied, open \'/root/.npm/_cacache/index-v5/e5/fa/acf6567ed8f4d89f375a561204919e71d6a6c0e7873e3fbb35148e93c04c\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'open',
npm ERR!   path: '/root/.npm/_cacache/index-v5/e5/fa/acf6567ed8f4d89f375a561204919e71d6a6c0e7873e3fbb35148e93c04c' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

┌───────────────────────────────────────────────────┐
│              npm update check failed              │
│        Try running with sudo or get access        │
│       to the local update config store via        │
│ sudo chown -R $USER:$(id -gn $USER) /root/.config │
└───────────────────────────────────────────────────┘
child_process.js:644
    throw err;
    ^

Error: Command failed: npm install
    at checkExecSyncError (child_process.js:601:13)
    at execSync (child_process.js:641:13)
    at Object.install (/usr/lib/node_modules/serverless-artillery/lib/npm.js:19:5)
    at Object.<anonymous> (/usr/lib/node_modules/serverless-artillery/postinstall.js:7:5)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
npm WARN<EMAIL_ADDRESS>requires a peer of bower@* but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR<EMAIL_ADDRESS>postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the<EMAIL_ADDRESS>postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-07-10T13_28_50_733Z-debug.log
root:~#

So after digging into this, it appears to be failing on the embedded npm install.
The ONLY way I've gotten this to work is by owning the entire node_modules directory as my user which obviously isn't a valid global context for installation on a a system.
I have multiple colleagues who have encountered this same error.  Please fix.

So after some digging I realize post install scripts don't run as root.
But you want me to install globally, which requires sudo, and the resulting folders are owned by root.  So the post install fails due to permissions issues.
So I have to ask, is NO ONE running npm with sudo?  How am I the only person who has had this issue?

Thanks for reaching out.
IMO running npm as root is not a very good idea. I'm not the only one:
https://news.ycombinator.com/item?id=16438889
https://givan.se/do-not-sudo-npm/
Given this, I don't believe we're actively testing this scenario.
IIRC, all the postinstall.js does is to do an npm install in the lib/lambda directory. You should be able to run that same command with elevated permissions or just node ./postinstall.js to work-around.
Thanks!
~Greg

Uhh, it doesn't work in a Docker container.  That's run as root.  Please tell me the alternative.
You specifically state in the readme to install globally.

Sure, globally. It makes no such recommendations about installing elevated.
We're happy to consider a PR if you'd like to provide a fix.

I've installed NodeJS via apt as per NodeJS instructions.  This means that global node modules are installed to /usr/lib/node_modules.
Hence, sudo install is necessary for global install.
Is the NodeJS community this broken that their own installation instructions are wrong?
That aside, your package is the first package I've come across that's doing an npm install in a post install script.  If you have further dependencies, why aren't they just part of your package.json so they're brought in as transitive dependencies?

The reason is that the lib\lambda directory constitutes the Serverless project which is deployed in order to provide the distributed load. Thus, it's a distinct project in and of itself and dependencies for that project are installed via npm.
This is the project code which is deployed when you run slsart deploy.
You can also directly export that project to modify to your liking, using the slsart configure command which will eject the project files into the current directory.

Thank you @gwsii for your graciousness.
@et304383 We're sorry that you've had a negative experience in using this tool.  You will have a higher productivity interaction with the open source community by remaining focussed on use cases, context, expectations, and curiosity.  We share our work for free, provide lot of documentation and a workshop, as well as live and asynchronous support channels.  To me your language read as a rather aggressive expression of your feelings mixed with a stance of entitlement.  The real problem with that, because negative feelings resulting from the frustrations of dealing with friction under conditions of uncertainty are normal, is that such expressions tend to create psychological artifacts that people feel they need to clear before dealing with the core issue.  Such artifacts distract from engaging in constructive, useful discussion (honesty: I add some in what follows but I'm also not the one trying to get things working).  None of us are compensated here for helping you - this is a broad truth about the OSS community so keep that in mind.

The ONLY way I've gotten this to work is by owning the entire node_modules directory as my user which obviously isn't a valid global context for installation on a a system.

It's not entirely clear what you are saying here but regardless, chowning (and equivalents) allows you to establish whatever rights you'd like for the subject files and can support whichever use case fits within the base OS constraints.

But you want me to install globally, which requires sudo, and the resulting folders are owned by root. So the post install fails due to permissions issues.

Actually, that's only the case if you installed node is such a way that your global node_modules is owned by root.  You have identified that you have such a circumstance but it is broadly rejected by the community as an anti-pattern.

Hence, sudo install is necessary for global install.

There are workarounds and it is common enough that NPM offers guidance on your issue: https://docs.npmjs.com/getting-started/fixing-npm-permissions. Given your use of docker, I'm surprised you're not using a container layer that provides you with nodejs in a known good state.  I'm sure you have your reasons.
We suggest (but don't demand) global installation for supporting a positive end initial user experience but don't actually "want" you to do it that way: I'm afraid we don't care enough and how you use the software is your domain.  We assume you know what you're doing, provide support for learning more, and provide a little value add.  You are perfectly able to install this tool into a local directory though you will have to establish an alias if you want to use the slsart command without qualification (i.e. an absolute path to the execution script) as you would in the standard user circumstance.

Is the NodeJS community this broken that their own installation instructions are wrong?

The community is supremely pragmatic, if not also a bit too willing to put up with cruft and legacy.  It absolutely doesn't shield people from having to understand the consequences of their actions or the best practices that result in secure effective software deployments.  In fact the blackhats of the community are happy to profit off those who are venturing far beyond their competence.
SUMMARY: @gwsii has offered you workarounds.  I have added a couple.  We are happy to support you in finding a workable arrangement of all your variables and more happy to work with you to identify a generalized resolution to your combination of variables and a better way to eliminate them as a PR.  Let's keep any such activity civil and focussed on constructive options.  Also, there are indicators in your experience that you are perhaps trying to operate outside of established best practices and you may want to consider revising accordingly.

To me your language read as a rather aggressive expression of your feelings mixed with a stance of entitlement.

Is everyone on the NodeJS community this easily offended?    I simply asked questions.  You choose to interpret text with attitude.  I cannot prevent that.
Do I appreciate the contributions?  Absolutely.  Have I taken your suggestions to heart for not running as root?  Yup.  I used the tarball package and installed locally in my home directory to get things working because I really wanted to use this tool.  It's a great tool and I absolutely appreciate the time and effort put into providing it.  Thank you very much for your work.

It's not entirely clear what you are saying here but regardless, chowning (and equivalents) allows you to establish whatever rights you'd like for the subject files and can support whichever use case fits within the base OS constraints.

I'm not chowning /usr/lib/node_modules to my user.

Actually, that's only the case if you installed node is such a way that your global node_modules is owned by root. You have identified that you have such a circumstance but it is broadly rejected by the community as an anti-pattern.

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
How is this an "anti-pattern"?  If one should not be doing this, NodeJS should stop telling people to do it.  Until then, I'm going to continue to install via one of the package installation methods supported via yum/apt.

Given your use of docker, I'm surprised you're not using a container layer that provides you with nodejs in a known good state. I'm sure you have your reasons.

https://hub.docker.com/_/node/
You're saying THIS isn't a good state?  This is the official NodeJS (and npm) Docker container.
docker run -it node:8 bash -c 'npm install -g serverless-artillery'

This doesn't work.

We suggest (but don't demand) global installation for supporting a positive end initial user experience but don't actually "want" you to do it that way: I'm afraid we don't care enough and how you use the software is your domain. We assume you know what you're doing, provide support for learning more, and provide a little value add. You are perfectly able to install this tool into a local directory though you will have to establish an alias if you want to use the slsart command without qualification (i.e. an absolute path to the execution script) as you would in the standard user circumstance.

You give readme instructions then state here that "oh that's not really what we want you to do"?  How is that helpful?  If you know now (perhaps you didn't before) that your software installation doesn't work when installed in a global context owned by root, then please update the README.  If you don't have time, I will offer my time to update the readme to state this limitation.

The community is supremely pragmatic, if not also a bit too willing to put up with cruft and legacy. It absolutely doesn't shield people from having to understand the consequences of their actions or the best practices that result in secure effective software deployments. In fact the blackhats of the community are happy to profit off those who are venturing far beyond their competence.

This attitude of the community, assuming everyone should just know better isn't helpful to anyone.  If anything, the fact that the community is recommending against using yum/apt to install (which sets up a root global modules scenario) is definitely not helping a case for NodeJS in enterprise use.
That said, I repeat that yours is the first package I've come across that wanted to do something in a post install script that breaks in a root global modules context.  So what is the work-around other than not installing NodeJS via apt/yum and not using the official Docker container?

Is everyone on the NodeJS community this easily offended?  I simply asked questions. You choose to interpret text with attitude. I cannot prevent that.

No offense here but some definitely are and the real problem is the time we've wasted on related factors; still social niceties are more pleasant.  Agreed.  Agreed.  I did share my perceptions, maybe you think they are abnormal; you get to but my observations suggest otherwise.  Agreed.

Thank you very much for your work.

You're welcome.  Thank you for expressing appreciation.

How is this an "anti-pattern"?

sudo npm is security risk and the use of sudo is an avoidable requirement.  Despite the legacy of the tool, we have observed broad agreement that this is a state to avoid.  Only running installations under a constrained set of rights (i.e. as a non-root user) reduces risk to your assets.  Here's a link for an example: https://blog.npmjs.org/post/141702881055/package-install-scripts-vulnerability.

This doesn't work.

You are right.  We have tipped to this effect, if not in one's face and on your discovery path, right (WARNING: may be harmful in non-OSx environments) here in the workshop.  That guidance has been in place since the London workshop where we started sharing slsart.

You give readme instructions then state here that "oh that's not really what we want you to do"? How is that helpful? If you know now (perhaps you didn't before) that your software installation doesn't work when installed in a global context owned by root, then please update the README. If you don't have time, I will offer my time to update the readme to state this limitation.

It was helpful in that the work arounds offered were means of getting yourself unblocked.  This is clearly a major problem in the legacy of nodejs to the point that the in situ package manager explicitly provides mitigatory documentation.  We were aware and had accepted the current behavior as acceptable due to the semantics of the preconditions for the issue.  Perhaps it would be safer to note it as of lower priority among the many demands on our time.
You seem to have misunderstood my statement about our "want".  I was declaring that we don't have desires about your actions with the tool or opinions about which of the many valid ways best meets each user's requirements.  We try to set users up for success and statistically speaking we're successful.  Clearly we have been unsuccessful in your case.  I can see how it would seem a bit of a "gotcha" that you got the outcome you have.  An unfortunate truth is that either the community has been deafeningly silent with us or your constellation of variables is outside the normal use case.  "must do as root" is not standard and is admonished within the *ix and BSD communities since time immemorial.  There are myriad strategies for doing better.  Usually we observe people installing the tool directly on their development machines under the context of their own user for interactive use.  The few previous users who have run into this issue have thought it was entirely reasonable to resolve the file rights rather than alter the tool and were glad to improve the state of their machines.  I, in fact, was glad to improve the state of my install when I was new to nodejs and hitting the learning curve.

This attitude of the community, assuming everyone should just know better isn't helpful to anyone. If anything, the fact that the community is recommending against using yum/apt to install (which sets up a root global modules scenario) is definitely not helping a case for NodeJS in enterprise use.

Welcome to the beast of OSS.  So many tools are ineffective, inconsistent, or insecure by default to facilitate a faster on-boarding experience and responsible use requires investment and knowledge.  Sorry for that: I didn't make it, I just try to improve it.  You do present an opportunity for this tool but I'll get to priority.

That said, I repeat that yours is the first package I've come across that wanted to do something in a post install script that breaks in a root global modules context.

True.  Also, it was explained why.  This tools has layers of meta that are not standard for a nodejs module.  It is not just a module for use on the local machine.  It is a module that contains asset declarations for deployment which are themselves a meaningfully separate and distinct module requiring dependencies.  That module itself is then distributed horizontally across a FaaS platform and engages in a distributed task execution.  We get that this creates a complex consideration for users but the relatively easy handling of it is why the tool is useful.  If you'd like to investigate why the npm installer's rights context is not being maintained across the process boundary and contribute a fix that resolves that for your use case, I think we'd be interested though I think its worth considering whether that would support unsafe practices.  It probably involves settings the uid and/or gid options in execSync (hereish).
Maybe we need to run the npm install within the process rather than execing out.  I don't imagine it will be our highest priority in the immediate future as we are focussed on productionizing monitoring mode.  While we are proud of this tool we have many other responsbilities to our sponsor.

So what is the work-around other than not installing NodeJS via apt/yum and not using the official Docker container?

We've shared a number.  The NPM link of moving the global lib dir seems plausible.  You may be able to replace npm i -g serverless-artillery with (try in pieces first please, not tested) npm i -g --ignore-scripts serverless-artillery && pushd $(npm root -g)/serverless-artillery/lib/lambda && npm i && popd as suggested earlier.  You've been mum on your use case and why the set of constraints that you're holding constant are necessary.  Perhaps you could help us understand why the standing on your left leg while balancing plates on a stick from your nose is important?  Yes, that's silly - you are being far more sensible than that, yet there are probably better approaches that perhaps we could recommend with more context.  Why is getting this into a docker container important?

First, let me say thank you for the civil response.  You could have easily gone the other way.
Regarding workarounds:
I firmly believe that NodeJS and NPM have been absolute dumpster fires since day one.  The entire framework and npm tool have been cowboy coded since inception, as evidenced by conflicting information (install via apt, but don't because sudo) and other unfortunate practices such as (until recently) publishing email addresses of npm package maintainers.
So it comes as no surprise to me that the recommended approach these days is to not run things as root.  I get that.  Avoid root wherever possible.
I have had such negative experiences working with npm, global installs vs local, etc that I try to avoid any action that can potentially hose my machine, and that includes running experiments in Docker containers.
Ignoring the container requirement (it's not critical) I install nodejs and npm via apt via Chef which I use to automate my machine.  The Chef nodejs cookbook has an npm_package resource that installs packages globally as Chef is running as root.  That is how I encountered this issue.
I understand now that this is not your typical project, so I get why your post install script is doing what it does.  The work-around I found about an hour ago was to use --unsafe-perm=true (appropriately named) which essentially accomplishes the same as you have suggested near the end of your post.
But as to why I want to stand on my left leg balancing plates on a stick on my nose (thanks for the laugh haha) - it's just how I've always thought of NodeJS and NPM packages.  Gobal is for globally installed system resources (no different than globally installing a package via apt) and not using the -g flag is for development.
I have never thought of "global" as just meaning global for me.  That would be like installing an apt package just for my personal user.  It's just not how I've ever used Linux.

I think it would save everyone a lot of time to simply state in the readme that the installation assumes your global node modules folder isn't owned by root, as is the case in a typical nvm setup.
Then a line about the alternative using the --unsafe-perm=true flag and strongly recommending against such a setup.

@et304383 (or anyone reading this later) regarding the use of slsart in docker containers, this is probably a helpful change: https://github.com/Nordstrom/serverless-artillery/pull/183/files


Getting error "AI provider openai not specified in configuration. Please run k8sgpt auth" while using k8sgpt cli with Azureopenai as backend

Checklist

[X] I've searched for similar issues and couldn't find anything matching
[X] I've included steps to reproduce the behavior

Affected Components

[X] K8sGPT (CLI)
[ ] K8sGPT Operator

K8sGPT Version
v0.3.29
Kubernetes Version
v1.29.1
Host OS and its Version
Windows
Steps to reproduce

k8sgpt auth default -p azureopenai
k8sgpt auth add --backend azureopenai --baseurl https://xxxxxx.openai.azure.com --engine gpt3-5 --model gpt-35-turbo

k8sgpt analyze --explain --filter=Pod

Expected behaviour
K8sgpt should give analyze results
Actual behaviour
Error: AI provider openai not specified in configuration. Please run k8sgpt auth
Additional Information
I checked this issue : https://github.com/k8sgpt-ai/k8sgpt-operator/issues/98 but didnt help

Having a similar issue with v0.3.40 + local ollama:
~> ollama serve &
~ » k8sgpt auth add --backend localai --model mistral --baseurl http://localhost:11434/v1
localai added to the AI backend provider list

~ » k8sgpt analyze --explain --filter=Service
Error: AI provider openai not specified in configuration. Please run k8sgpt auth


Rename .yml extensions to .yaml

Be consistent with file extensions. Use yaml instead of yml.

If it passes test, LGTM.


connectivity-check: Use unprivileged ports

Use of port 80 causes unnecessary requirements for k8s environments to
allow pods to bind to privileged ports. Switch to port 8080 instead.

@sayboras

Just curious if there is any plan to use unprivileged ports for cilium services as well. If I am not wrong, some hubble related service might still use port 80.

I think the Hubble related services you might be referring to (hubble-relay and hubble-ui) are only using port 80 on the service frontend, but not the container (target) port. hubble-relay listens on port 4245, hubble-ui on port 12000.
In that case, I don't think we suffer the problem this PR is addressing (which is fixing up the container ports)


i2b_PVK_bio: don't set PEM_R_BIO_WRITE_FAILURE in case of success

but in case of an error
CLA: trivial

I assume this is not tested anywhere.
It looks like apps.c can load this format? Ideally we would load one of the keys to test it.

PVKs, are they still around?

24 hours has passed since 'approval: done' was set, but this PR has failing CI tests.  Once the tests pass it will get moved to 'approval: ready to merge' automatically, alternatively please review and set the label manually.

Merged to master and 1.1.1
Thank you for the PR.


some questions about this Bot

Hi, This Bot is very useful for me
i have few question about this bot

can i post tweets  without images?
is it possible to create White list and Blacklist for search query
how can i search based on location

Hi @LeonardoDavid I am glad you like it. Be careful how you use it or you get shut down by Twitter instantly.

Just remove the code for the media upload in reply.js.
The database is a blacklist of Twitter users. You may add users yourself beforehand. Or what kind of white-/blacklist are you looking for?
You would need to extend the code to add a geocode parameter like for lang

Hope that helps.

Hi, analog-nico Thanks for your replay
i  have few more doubts

i am running this bot on my windows pc, right now i am able to run only one bot  at a time is it Possible to run more than one bot at a time. i created a new bot for a different twitter account when i run it i get this error message.

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: listen EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at Server._listen2 (net.js:1156:14)
    at listen (net.js:1182:10)
    at net.js:1280:9
    at dns.js:85:18
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3

2.is it Possible to run this bot on google cloud

Regarding 1 just remove this code and then you can run multiple bots locally.
Regarding 2 you have to find out yourself I am afraid of.

Hi, Thanks for the answers,
to prevent the Bot from reaching twitter api rate limits, i think we can add muliple api keys and rotate the Api keys every 15 minutes the bot runs is it Possible if yes, can you tell me how

Please read the Don't spam! section of the README. It links important sources that allow you to decide if you are heading in the right direction.
As far as I can tell you are underestimating Twitter's spam detection mechanisms and want to push the amount of replies too far. For that I can no longer be your accomplice. I am sorry.

i am not trying to spam however thank you for your time

It is good to hear that you have good intentions. Happy coding!

i am learning to code for about an year i am beginner in Python and JavaScript, could suggest me any tutorial for the last question i asked you

Mmh, good question. I learned a lot from the free material of https://teamtreehouse.com back in the day. If you sign on for a free trial you may find good courses about node.js. Or ask Reddit.

Hey buddy, if you promise me you don't spam then you may find the answer to key rotation in this issue: https://github.com/analog-nico/twitter-reply-bot/issues/2

Hi,
Thank you

Hi, i wanted to Post Tweets Without Images, like you said i removed  Media Upload code in replay.js
but i am getting a error when i am running this
here is the Error Message
Unhandled rejection TypeError: Cannot read property 'text' of undefined
    at compileTweet (C:\Users\LEONARDO\Desktop\bot\nodejs\Tester\lib\responses.js:10:38)
    at Object.module.exports.getNextTweet (C:\Users\LEONARDO\Desktop\bot\nodejs\Tester\lib\responses.js:30:16)
    at C:\Users\LEONARDO\Desktop\bot\nodejs\Tester\server.js:66:43
    at tryCatcher (C:\Users\LEONARDO\Desktop\bot\nodejs\Tester\node_modules\request-promise\node_modules\bluebird\js\main\util.js:26:23)
    at Promise._settlePromiseFromHandler (C:\Users\LEONARDO\Desktop\bot\nodejs\Tester\node_modules\request-promise\node_modules\bluebird\js\main\promise.js:507:31)
    at Promise._settlePromiseAt (C:\Users\LEONARDO\Desktop\bot\nodejs\Tester\node_modules\request-promise\node_modules\bluebird\js\main\promise.js:581:18)
    at Async._drainQueue (C:\Users\LEONARDO\Desktop\bot\nodejs\Tester\node_modules\request-promise\node_modules\bluebird\js\main\async.js:128:12)
    at Async._drainQueues (C:\Users\LEONARDO\Desktop\bot\nodejs\Tester\node_modules\request-promise\node_modules\bluebird\js\main\async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\LEONARDO\Desktop\bot\nodejs\Tester\node_modules\request-promise\node_modules\bluebird\js\main\async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:367:17)

Here is my reply.js code

'use strict';

var BPromise = require('bluebird');
var Twitter = require('twitter');

var client = new Twitter(require('../settings.json').twitter_api);

module.exports = function (compiledTweet) {

    return new BPromise(function (resolve, reject) {

        var data = require('fs').readFileSync(compiledTweet.image);

            if (err) {
                reject(err);
                return;
            }

            console.dir(media);

            if (!media || !media.media_id_string) {
                reject(new Error('Image upload failed.'));
                return;
            }

            var status = {
                in_reply_to_status_id: compiledTweet.replyTo,
                status: compiledTweet.text,
                media_ids: media.media_id_string
            };

            client.post('statuses/update', status, function (err, tweet, response){

                if (err) {
                    reject(err);
                } else {
                    console.dir(tweet);
                    resolve(tweet);
                }

            });

        });

    };

"Cannot read property 'text' of undefined" means that you access the property .text of a variable that is undefined. If you search your code for "text" you find "compiledTweet.text". That means compiledTweet is undefined.

hi, can you give me  link to the Twitter API Library you used

https://www.npmjs.com/package/twitter

Hi,
to import random twitter API Keys i replaced credential code in request.js
var twitter_api= require('../settings.json').twitter_api;

var credentials = twitter_api[Math.floor(Math.random()*twitter_api.length)];

But i am getting this error
Unhandled rejection Error: [object Object]

You may use process.on('unhandledRejection', ...) to catch the rejection and look into its cause.

Hey i did not full error messages last time These are the errors i am getting
Unhandled rejection Error: [object Object]
    at Object.ensureErrorObject (C:\Users\LEONARDO\Desktop\TwitterApp\node_modules\request-promise\node_modules\bluebird\js\main\util.js:261:20)
    at Promise._rejectCallback (C:\Users\LEONARDO\Desktop\TwitterApp\node_modules\request-promise\node_modules\bluebird\js\main\promise.js:469:22)
    at Promise._settlePromiseFromHandler (C:\Users\LEONARDO\Desktop\TwitterApp\node_modules\request-promise\node_modules\bluebird\js\main\promise.js:513:17)
    at Promise._settlePromiseAt (C:\Users\LEONARDO\Desktop\TwitterApp\node_modules\request-promise\node_modules\bluebird\js\main\promise.js:581:18)
    at Async._drainQueue (C:\Users\LEONARDO\Desktop\TwitterApp\node_modules\request-promise\node_modules\bluebird\js\main\async.js:128:12)
    at Async._drainQueues (C:\Users\LEONARDO\Desktop\TwitterApp\node_modules\request-promise\node_modules\bluebird\js\main\async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\LEONARDO\Desktop\TwitterApp\node_modules\request-promise\node_modules\bluebird\js\main\async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:367:17)

i searched google found solution for few but i dont know which code i need to change

Granted, the stack trace doesn't help. The issue is that somewhere in the context of a Promise an Error is thrown. The Promise, however, has no .catch(...) handler. Thus an "unhandled rejection" is produced.
If you can solve this you definitely improved your JavaScript skills by a big step!

can you tell me which code and which line i need to fix

Take that as a challenge to improve your skills. You can do it!
Best way to approach this is to get a debugger running. Webstorm contains a very user friendly one.

HI,
i have been trying for 2 days i still cant figure out whats wrong. i think my code for importing random keys might be wrong
is the code is right or wrong
'use strict';

var request = require('request-promise');
var _ = require('lodash');

//var credentials = require('../settings.json').twitter_api;
var twitter_api= require('../settings.json').twitter_api;

var credentials = twitter_api[Math.floor(Math.random()*twitter_api.length)];

function getRequestOptions(options, includeUserToken) {

    _.assign(options, {
        oauth: {
            consumer_key: credentials.consumer_key,
            consumer_secret: credentials.consumer_secret
        },
        headers: {
            'Accept': '*/*',
            'Connection': 'close',
            'User-Agent': 'node.js'
        },
        json: true
    });

    if (includeUserToken) {
        _.assign(options.oauth, {
            token: credentials.access_token_key,
            token_secret: credentials.access_token_secret
        });
    }

    return options;

}

module.exports = function (options, includeUserToken) {

    options = getRequestOptions(options, includeUserToken);

    return request(options);

};

Since your random key importing works well - I tested it - the error is produced somewhere else.
Whatever your error is it should have been caught here. I get the impression you somehow changed the code in other parts that at least screwed the promise chains up so that the error doesn't get caught properly but instead results in an Unhandled rejection.
To get more insights into your error add these lines to server.js right below the require statements:
BPromise.onPossiblyUnhandledRejection(function (err) {
    console.dir(err);
});

Instead of "Error: [object Object]" you should see now the contents of the object. Or even better, use your debugger, put a breakpoint on the console.dir line, and take a closer look at err when the execution stops there.
Use your debugger to step through everything and with that zero in on the cause! If you want to improve your debugging skill in general this book is a real gem: https://www.amazon.com/Debugging-David-J-Agans-ebook/dp/B002H5GSZ2 It is one of a handful books which really stand out from all the books I read in my life!


display attribution for openstreetmap buildings

done! Also moved mapbox logo to left of screen per there attribution page description


Type 'classname' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.

Typescript: 3.0.1 insiders
VSCode Version: 1.26.0 insiders
OS Version: Windows 10

I get the above message in the Problems window when I use an Iterator<> that I have added to my class
Tsc does not report anything on the command line and the all tests run fine. So I don't know if this is a vscode issue or I should take that up with the Typescript guys.
   for (const v of t) {
     result.push(v);
   }

I have added this option to my tsconfig file in my workspace:
"target": "es5",
 ...
 "lib": [
    "es2015", "dom", "es6"
 ],
...
"downlevelIteration": true,

The issue exists in vscode 1.25.1 with tsc 2.9.2 as well.

Do you see this problem reported when running tsc 3.0.1 from the command line against that tsconfig?

Not able to reproduce in 3.0.1. I'll close this


Solidity 0.7.x constructor without visibility breaks parser

I encountered the below issue using Solidity 0.7.1
Error: Constructors have to be declared either "public" or "internal"

Thanks! 👍


DRAFT: CAS2 Domain Events

Context
CAS2 would like to start emitting Domain Events:

Initially just to log when an Application has been marked as submitted.
We don't currently have a defined consumer of this API yet, so we will save and expose a set of basic information.

In light of the refactoring work being done to implement a cas2 namespace in the API I think it makes sense to also namespace the Domain Events API. My understanding of how the CAS 1 Domain Events work currently is this:

When an Application is saved successfully, we create a DomainEvent which is saved to the database. Some of that data is published to the Domain Event SNS, along with a URL that any listeners can use to view the full Domain Event.
We have a Domain Events Controller with an endpoint for getting a Domain Event by ID.
I propose we do a similar thing for CAS2, but with a namespaced endpoint, e.g. instead of events/application-submitted/{eventId} it would be /events/cas2/application-submitted/{eventId} and it will return a CAS2 specific Domain Event.
Although there will be some shared fields on the models, if this ADR on handling NOMIS users in CAS2 without inheritance goes ahead, I think we should follow the tradition of not using inheritance/polymorphism for the same reasons - keeping it simple, less risk of touching production code.

Questions

Controller separation:

it makes logical sense for the path for the CAS2 domain events to be under the events path, so e.g. events/cas2/applications-submitted etc. It also makes sense for us to have our own Cas2DomainEventsController.
However, this means that in the code the controller functions would be generated under the same EventsApiDelegate. When trying to create a Cas2DomainEventsController the code was complaining that it needed to have unique bean for the delegate. (I think? So I think a @Service annotated Controller has to have a one-to-one relationship with the EventsApiDelegate? )
So I couldn't figure out a way to extend or override the eventsCas2ApplicationSubmittedEventIdGet from the DomainEventsController, that actually worked. If anyone has any ideas would be very grateful! Atm I am just calling another method from the DomainEventsController.

To Do

create the CAS2_ROLE_EVENTS in dev environment

closing this because of changes to API namespace and CAS3 domain event work, will open new PR


Make NumAsHex extensions public

Specifically, these extensions:
    extension NumAsHexProtocol {
        init?(_ data: Data) {
            let value = BigUInt(data)

            self.init(value)
        }

        func serialize() -> Data {
            value.serialize()
        }
    }

Seems like all the others are already public 😄


Does not install in ubuntu No such file or directory: '/etc/supergfxd.conf'

Hey, install:
asusctltray$ sudo bash -x ./install.sh
+ ((  EUID != 0  ))
+ cp asusctltray /usr/local/bin
+ chmod a+x /usr/local/bin/asusctltray
+ cp asusctltray.svg /usr/share/pixmaps
+ cp asusctltray.desktop /usr/share/applications

After running I get:
$ asusctltray
Traceback (most recent call last):
  File "/usr/local/bin/asusctltray", line 333, in <module>
    TrayIcon()
  File "/usr/local/bin/asusctltray", line 84, in __init__
    with open(GFX_CONF, "r") as file:
FileNotFoundError: [Errno 2] No such file or directory: '/etc/supergfxd.conf'

Versions
$ asusctl --version

App and daemon versions:
     asusctl v3.5.1
       asusd v3.7.2

Component crate versions:
   rog-anime v1.0.5
    rog-aura v1.1.0
    rog-dbus v3.5.1
rog-profiles v0.1.2
   rog-types v3.2.0

Do you have supergfxctl installed and working correctly?

Ok, I had to install supergfxctl and then to enable it.
and also apt-get install power-profiles-daemon
That solves the issue.


Simplify F.pad test

LGTM. Jenkins, test this please.

Jenkins CI test (for commit 5fe4c10e0706eb5f7d0232c3851ff753802a9b09, target branch master) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

The chainer-py2 test is failing after this PR.  The cause seems the order of with_requires and inject_backend_tests.

I've posted a PR to fix the problem as #6478 .


Support for OpenLiberty as MP 2.2.

Fixes #128

Comments from https://github.com/eclipse/microprofile-starter/pull/129 are addressed. Good to merge


tox target to enforce pep8

This will help nudge future PR authors to fix style related issues

Current coverage is 94.52% (diff: 100%)

Merging #97 into master will not change coverage

@@             master        #97   diff @@
==========================================
  Files             9          9
  Lines           658        658
  Methods           0          0
  Messages          0          0
  Branches          0          0
==========================================
  Hits            622        622
  Misses           36         36
  Partials          0          0

Powered by Codecov. Last update c147f66...5c82309


clang-cl expects x64, not x86_64

Having run:
xwin splat --output vendor

I want to compile a program with clang-cl on Linux, but lld-link can't find the required libraries on the expected library path:
clang-cl -vctoolsdir vendor/crt/ -winsdkdir vendor/sdk -fuse-ld=lld -v test.c
...
"/usr/bin/lld-link" -out:test.exe -libpath:vendor/crt/lib/x64 -libpath:vendor/crt/atlmfc/lib/x64 -libpath:vendor/sdk/Lib/10.0.20348/ucrt/x64 -libpath:vendor/sdk/Lib/10.0.20348/um/x64 -nologo /tmp/test-eb99a8.obj
lld-link: error: could not open 'libcmt.lib': No such file or directory
lld-link: error: could not open 'oldnames.lib': No such file or directory
lld-link: error: could not open 'uuid.lib': No such file or directory
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)

If I manually symlink the nested x86_64 subdirectories to x64, the above clang-cl command completes successfully.

You need to use --preserve-ms-arch-notation to use the /vctoolsdir and /winsdkdir options

Thanks; I didn't realise the subcommands had help.


cherrypick

cherrypick change in https://github.com/istio/istio to installer

Can you update the change description to include what it does and why ? I thought namespace
is already available as an environment variable defined by k8s.

updated description to put Istio PR link, the change on yaml is borrowed from pilot - https://github.com/istio/istio/blob/master/install/kubernetes/helm/istio/charts/pilot/templates/deployment.yaml#L98

Never mind, found the info, updated the title.
/lgtm  - not very happy with using NAMESPACE when injector uses POD_NAMESPACE, but maybe we'll change the injector env instead for consistency...


i can`t start bot

node main.js
[ './andy.json' ]
SES_UNCAUGHT_EXCEPTION: {}
Agent process exited with code<PHONE_NUMBER> and signal null
Agent process ./andy.json exited too quickly and will not be restarted.
All agent processes have ended. Exiting.

What version of NodeJS are you using? Which OS? Needs more info.

I have the same problem, I'm using Ubuntu, and the latest js

You may have to create a specific API key for OpenAI and assign it to the models you want to use. Simply using the default settings in andy.json probably won't work out of box. See below, I configured my API key to use chatgpt-4o-latest instead of the default.
My system:
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       noble

The bot:
~/devel/mindcraft$ node main.js
[ './andy.json' ]
Starting agent with profile: ./andy.json
Starting agent initialization with profile: ./andy.json
Initializing action manager...
Initializing prompter...
Using chat settings: { model: 'chatgpt-4o-latest', api: 'openai' }
Using embedding settings: { api: 'openai' }
Initializing history...
Initializing coder...
Initializing npc controller...
Initializing memory bank...
Initializing self prompter...
Initializing examples...
Error with embedding model, using word overlap instead.
Error with embedding model, using word overlap instead.
Logging into minecraft...
Loaded memory: Base: forest biome (2320.7, -51, 1441.3); current savanna. Goals: survival, upgrade tools, efficient crafting. ClearLag affects items. Issues: crafting command error ('Player not found') persists; retry fixes or !restart. Task: gather table materials, make wooden pickaxe, mine stone. Nearby: stone, dirt, ores, etc. Attempted incorrect !mine command; corrected to !collectBlocks. Focus: adapt commands, resolve glitches, optimize tasks. Use !rememberHere for key spots.
Logged in!
Prismarine viewer web server running on *:3000

Let's start with the whole log to see if something else is happening above what your screenshot shows.


Use Vuex store & component-ize app

Because I like to torture myself.

Switching to vuex is mostly done, component-izing next.

This is complete, Will merge to master in a few hours.

forgot to close lmao


cmd/api: failing on linux-arm builder due to non-devel Go version

https://build.golang.org/log/89d71a5b0369a691899c3435abc7df3d4abd4074
##### API check
Error running API checker: exit status 1
Go version is "builder host-linux-armel-cross", ignoring -next /home/builder/stage0scratch/workdir/go/api/next.txt
[ a lot of +pkg ... lines ]
exit status 1
2018/04/07 13:27:59 Failed: exit status 1
2018/04/07 13:28:04 FAILED

The fact that the version does not contain devel implies that +pkg lines, i.e. new APIs, are a test failure:
fail = !compareAPI(bw, features, required, optional, exception,
        *allowNew && strings.Contains(runtime.Version(), "devel"))

The fact that no other builder hits this tells me that the version in this ARM builder is wrong; it should contain devel.

/cc @zeebo @bradfitz

@bradfitz the builder is still seeing the same failures. Do we require manual action to apply your dashboard fix above?

I haven't deployed it

Ah, apologies for the noise - I thought this was somehow automated.

Ping @rsc. What do you think the VERSION file should contain in these cases?

@bradfitz The reason for the change is, essentially, to avoid having the string "devel" appears in the third field of the output of  go tool compile -V=full.  When the string "devel" appears there, the code in cmd/go/internal/work/buildid.go, function (*Builder).toolID, uses a hash of the compiler binary for the build ID.  When "devel" does not appear, (*Builder).toolID just hashes the version string itself.  The effect is that for released compilers we get the same build ID regardless of whether we are using a cross-compiler or not.
The output of go tool compile -V=full is generated by cmd/internal/objabi/flag.go based on the value of version in cmd/internal/objabi/zbootstrap.go.  That file is generated by mkzbootstrap in cmd/dist/buildruntime.go, where version is set to the result of findgoversion, which is the function you are asking about.
So this all boils down to: findgoversion can return anything that doesn't start with "devel".  That will ensure that the build ID of the packages built on the cross-compiler host will be the same as the build ID of the packages on the target, and will thus avoid rebuilding lots of packages on the target.
Other than not starting with "devel" I don't think it really matters what we put in the VERSION file on the builders.  It could be more or less anything, since the files don't escape the builders anyhow as far as I know.

@ianlancetaylor, one medium-term goal for the builders is to use cmd/go's build+test cache infrastructure across builds, at least for trybots. If we put the git commit hash in the VERSION, doesn't that get mixed in to the action ID / cache keys? Can I just use a static string for all builds, like "golang-x-build"?

I don't understand how we can safely use the cache across builds across CLs.  If a CL changes the compiler, then we definitely do not want to pick up an cached build result built by an earlier version of the compiler.

@ianlancetaylor, I assumed the digest of the compiler/linker/assembler bits were part of the cache. I just don't want some arbitrary string to be part of the digest unnecessarily.
If a given commit only touches a comment in some test file, I want to have an identical compiler/linker/assembler from the previous commit, and then reuse all the built packages & test results.

If go tool compile -V=full prints a string that contains the string "devel", then the digest of the compiler will be part of the cache.  If it does not, then only the -V=full output will be part of the cache.  If there is a VERSION file, then the string "devel" will be printed if and only if the VERSION file contains the string "devel".  So we could perhaps use "devel golang-x-build".
At least, that is my understanding.


fix: Regenerate grub config properly and fix upstream uefi configs

Enhancement:

Apply a workaround of changing timeout in grub config directly only on RHEL 7 where it is really needed
Fix _bootloader_uefi directories for other than RHEL distributions
Reason: On UEFI systems, the __bootloader_grub_conf config does not have a full config initially, but a stub redirects to a common config in /boot/grub2/grub.cfg. This is not the case on RHEL 7, so using an older approach of regenerating the config when changeing timeout

Result: The role works properly on BIOS on UEFI systems

[citest]

I provisioned a PowerPC machine in Beaker, and it uses grub, my tests passed on it.
s390x machine uses a different bootloader zipl, role doesn't support it

[citest]

[citest]

[citest]


Base theme CSS not merging with parent theme

Version

@nuxtjs/tailwindcss: v6.6.6
nuxt: v3.4.2

Reproduction Link

CodeSandbox Example

Steps to Reproduce

Set up an application using @nuxtjs/tailwindcss that extends a base theme, such as the "base-theme" demonstrated in the provided CodeSandbox link.
Ensure both the base theme and the parent theme include assets/css/tailwind.css files.
Notice that the base-theme/assets/css/tailwind.css file from the base theme is not taken into account.

Expected Behavior
The application should merge the base-theme/assets/css/tailwind.css file from the base theme with the parent theme's assets/css/tailwind.css file.
Actual Behavior
The application only loads the parent theme's assets/css/tailwind.css file, ignoring the base-theme/assets/css/tailwind.css file from the base theme.

There are a couple of things that can be considered.

We read the layer's cssPath file, and the app's cssPath, put the two together (with \n in between) in a new file using addTemplate, but this would be very fragile.
Create another template that has @import "{cssPaths}" for all layers through postcss-import - can't say the reliability of it with Tailwind for now, if you'd like to brainstorm & test, please do so 🙂
The styles in your reproduction can/should rather be added as Tailwind plugins into the configuration - see https://tailwindcss.com/docs/plugins#adding-utilities

Let me know how you solve it. I'll close this issue for now as it is believed to be out-of-scope.


Refactor Sim with State Machine functionality and basic State Transition logic

Currently the sim runs everything in main where it instantiates and operates a spacecraft obejct rn that's SimpleSat
The desired sim architecture works such that there are different state machine modes and state transition logic
The desired sim workflow is to use the src/main.cpp as a place for the user to instantiate the spacecraft like it already is, but also instantiate the state machine's modes as well as its transition logic such that users can easily and finely customize the mission  design as desired.

basically closed, some basic states and transitions for the machine are implemented for the basic hohmann transfer + RSW pointing SimpleSat sim in src/main.cpp


PDF is not viewable on Safari, after v2.0

Device
iPad Pro 10.5
Version
iOS 17.5.1
Passcode?

[X] Passcode is enabled.

Start going into detail..
After the v2.0 update, I cannot view PDF files within Safari. The file is downloaded but the page is blank. From that blank page, I can open the file with other apps like goodreader, acrobat reader and also can save the file to a iCloud folder. I go back to v2.0.0 beta 9.2 on my iPad Pro 10.5 with ios17.5.1, and PDF file viewing within Safari comes back to work. Chrome behaves the same way as well.
Familiarity with palera1n

[X] I am familiar with palera1n and how to use it!

Familiarity with CLI

[X] I am familiar with the command-line!

ill try this on my iPad 7 shortly after im done installing Windows 11 IoT, assuming something is breaking webkit it will definitely react the same on Chrome, now if thats due to a bad tweak of palera1n itself im going to try shortly

Unfortunately, PDF is still not viewable within safari with v2.1-beta.1. Does is work on other ios versions? I am still at 17.5.1, so if it is viewable on other versions I will consider to upgrade.


runtime: pageAlloc.allocToCache updates pageAlloc.searchAddr in an invalid way

Currently the page allocator's allocToCache method can update the search address in such a way that it doesn't point into memory contained in pageAlloc.inUse, which violates a documented property.
The result of this is an occasional crash. A similar bug was fixed prior to the Go 1.14 release with https://golang.org/cl/216697, but that failed to take into account allocToCache. This is causing real failures and we should fix it ASAP. We should also backport it as there is no workaround available when you do run into it.

@gopherbot Please open a backport issue for 1.14.

CC @aclements @prattmic

This and the CL mentioned in the issue aren't a factor in 1.13?

@networkimprov That's correct.


Fix code scanning alert - Semgrep Finding: javascript.sequelize.security.audit.sequelize-injection-express.express-sequeliz...

SQLi
Tracking issue for:

[ ] https://github.com/merveesari/juice-shop/security/code-scanning/168

https://github.com/juice-shop/juice-shop/commit/7a2b7de13a044eff84792a6fcf16e4187e39dfb2
ile kapatılmıştır.


Update secdownloading.py to new archive URL for SEC financial markets…

The SEC has changed its landing page and structure for the financial statement data sets. They have retained the old landing page and datasets at an archive URL. I've just updated to this URL but it appears the data in this old structure will no longer be updated. This gets the package back to running as original designed at least for the time being.

@rcurrie
Thanks for your input, Rob.
I just created a new version that looks at the content in the new archive and current locations. So it will work again and I will check where the new zip files will be created, as soon as 2024q4 is available.

Sounds good, will check the new version out!


dependencies error with django 4.1.9

ERROR: Cannot install -r requirements.txt (line 3) and asgiref==3.4.1 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested asgiref==3.4.1
    django 4.1.9 depends on asgiref<4 and >=3.5.2

changing asgiref version to 3.5.2 is ok.

@GoldschmittGabriel Please check if fixed on main branch and close issure if fixed. Thanks :)

retested it, should be fixed


doc/md: fixing a formatting error in writing-docs documentation

Bullet point 3 did not start a new list item since a line break was missing.

❤

Uh, dang that. I made a mistake :scream:

Lemme create a new PR. I am sorry :cry:


Added near sign message

@amirsaran3 this looks good and follows the current state of the NEP let's leave it as a draft until the NEP gets approved.

Sorry @kujtimprenkuSQA accidentally nuked your comment! 😬
Comment was:

@amirsaran3 this looks good and follows the current state of the NEP let's leave it as a draft until the NEP gets approved.


model.save() throwed out an OSError: Unable to create file(error message = 'resource temporarily unavailable')

Well, I build a keras model, and since sometimes my dataset is too large to fit into the memory, and a memoryError throwed out. Thus, I searched and figured out that I need to implement a generator class inherited from keras.utils.Sequence, so that I can use model.fit_generator and model.predict_generator.
And I have several callbacks in my fit_generator function, which includes ModelCheckpoint to save my model as a .hdf5 file, and I use use_multiprocessing=True, workers=16 in my fig_generator` function.
Here is a snippet of this function:
        self.model.fit_generator(generator=training_generator,
                                 validation_data=validation_generator,
                                 epochs=epoch,
                                 use_multiprocessing=True,
                                 workers=8,
                                 callbacks=monitor,
                                 verbose=2)

The error message is attached below:

Epoch 00005: val_loss did not improve
Epoch 6/15
 - 135s - loss: 52.3622 - val_loss: 74.5698

Epoch 00006: val_loss improved from 74.99819 to 74.56982, saving model to models/002008.SZ/model.hdf5
Epoch 7/15
 - 135s - loss: 52.3163 - val_loss: 74.2776

Epoch 00007: val_loss improved from 74.56982 to 74.27758, saving model to models/002008.SZ/model.hdf5
Traceback (most recent call last):
  File "/root/.pycharm_helpers/pydev/pydevd.py", line 1664, in <module>
    main()
  File "/root/.pycharm_helpers/pydev/pydevd.py", line 1658, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/root/.pycharm_helpers/pydev/pydevd.py", line 1068, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/root/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/data/CNN_dlw_v0/CNN_dlw/main.py", line 100, in <module>
    main()
  File "/data/CNN_dlw_v0/CNN_dlw/main.py", line 72, in main
    model.train(epoch=15)
  File "/data/CNN_dlw_v0/CNN_dlw/Model.py", line 383, in train
    verbose=2)
  File "/data/SkyCompute/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/data/SkyCompute/lib/python3.6/site-packages/keras/engine/training.py", line 2280, in fit_generator
    callbacks.on_epoch_end(epoch, epoch_logs)
  File "/data/SkyCompute/lib/python3.6/site-packages/keras/callbacks.py", line 77, in on_epoch_end
    callback.on_epoch_end(epoch, logs)
  File "/data/SkyCompute/lib/python3.6/site-packages/keras/callbacks.py", line 447, in on_epoch_end
    self.model.save(filepath, overwrite=True)
  File "/data/SkyCompute/lib/python3.6/site-packages/keras/engine/topology.py", line 2576, in save
    save_model(self, filepath, overwrite, include_optimizer)
  File "/data/SkyCompute/lib/python3.6/site-packages/keras/models.py", line 106, in save_model
    with h5py.File(filepath, mode='w') as f:
  File "/data/SkyCompute/lib/python3.6/site-packages/h5py/_hl/files.py", line 271, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
  File "/data/SkyCompute/lib/python3.6/site-packages/h5py/_hl/files.py", line 107, in make_fid
    fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5f.pyx", line 98, in h5py.h5f.create
OSError: Unable to create file (Unable to lock file, errno = 11, error message = 'resource temporarily unavailable')
^C
Process finished with exit code 1

Notice that sometimes the model is successfully saved, but it seems to me that it's a probability thing, after several save action, it will be more probable to cause this OSError.
I think it could be that I set the use_multiprocessing=True and workers=16 which makes some process is trying to save the file while another process is also trying to access this same file? I'm not quite sure exactly what happens here. I think the keras should have some internal control which would prevent this.
Edit: When I set use_multiprocessing=False, this OSError stopped from popping up, however, since no multiprocessing, the training procesure is much slower now. One not so elegant solution I can think of is not using ModelCheckpoint, and only save the model after training so I can still use multiprocessing in training, but in this way I will not be able to save the model which corresponds to the one with smallest val_loss. :<
Edit2: I checked that my keras version is 2.1.4

I am having this same issue using fit_generator with use_multiprocessing=True and callbacks=ModelCheckpoint. I'm using keras 2.2.2.

the version of keras/engine/saving.py on the keras master branch uses f = h5dict(filepath, mode='w') instead of h5py.File(filepath, mode='w') as f: and there is some extra logic dealing with closing the h5 file if it has been opened. Perhaps it might be a good step to try installing the version of keras on master and trying that.
I think there might be an error in the logic in save_model  in keras/engine/saving.py that determines whether f.close() is executed. Shouldn't f.close() be executed irrespective of whether 1opened_new_fileisTrueorFalse`?
    try:         _serialize_model(model, f, include_optimizer)     finally:         if opened_new_file: f.close()
...

We're experiencing the same issue using the "model_checkpoint" callback, we also have use_multiprocessing=True

Just came across the same problem. Figured out that I was using too many workers (4 in my case), lowered to 2 and this error disappeared, while not hurting the training performance.

@hermesribeiro But the trainin speed is lowered right?

I noticed the same issue using Keras 2.2.2.  There is no error on the first checkpoint however the model file created is empty.  The second checkpoint the error is raised.   I have no issues if I use the keras 2.1.6-tf  bundled with tensorflow 1.10.1.
More Details:

OS: Ubuntu 18.04
Python: 3.6.5
Keras: 2.2.2
Tensorflow: 1.10.1
h5py: 2.8.0

I reinstall Keras 2.2.0, problem solved

Same problem here, after the second iteration the model cannot be saved.
I'm using Keras 2.2.2, Tensorflow 1.10.1 and h5py 2.8.0, multiprocessing=True and fit_generator, with the only callback of ModelCheckpoint

Interestingly, my problem also gets solved by changing to keras 2.2.0: https://github.com/keras-team/keras/issues/10948#issuecomment-423767210
However, I still have the resource temporarily unavailable issue a lot too. I usually resort to either only saving the last model, or saving to a new file each time.

Same issue with Keras 2.1.3 and Tensorflow-gpu 1.4.1.

Same issue with Keras 2.2.4 and Tensorflow-gpu 1.11.0. As a workaround you can use the formatting options of the filepath described in https://keras.io/callbacks/#modelcheckpoint in combination with save_best_only=True. This way you will end up with multiple saved models, but since save_best_only = True, you will not have all of them saved. So the last one with the highest epoch in name will be the best.
E.g. you can use this name '{epoch:02d}-{val_acc:.2f}.hdf5' to get `01-0.99.hdf5' saved on your disk.

Same issue with Keras 2.1.3 and Tensorflow-gpu 1.4.0.

Same issue pop up today on GoogleColab with Keras 2.2.4.

I'm still seeing this problem in Keras 2.2.4 using fit_generator with a Sequence class to serve up the training and validation data instead of a generator. I've been getting around the problem by not using ModelCheckpoint at all. Instead I use the EarlyStopping callback with restore_best_weights=False - and then I save the best weights after the model finishes training. Hope this helps!

My computing environment automatically shuts down after a period, so I was trying to use ModelCheckpoint to save the latest model. My workaround is to create a new callback which saves models/weights after each epoch with a new file name.
Calling model.save() or  model.save_weights() in my new callback still causes OSError: Unable to create file error. Saving with a new file name solves the problem for me. In the same on_epoch_end() method, I delete the old file after successfully saving the new one.

I am also finding this same issue. Using the ModelCheckpoint callback, trying to save the model after its already been saved successfully once before. (and using multiprocessing)

I have the same issue with the Keras on 2.2.4. I am using Ubuntu 18.10, installed Keras and tensorflow with Anaconda, and am using multi_processing to speed up training, but there is usually this same error after the second or third epoch with training.

The error occur after 2,3,4 epoch of training - first timr when your keras
try to save new best weight and previous file exists. He dont know to
delete old file.
On Nov 14, 2018 9:13 PM, "Jacob Bieker"<EMAIL_ADDRESS>wrote:

I have the same issue with the Keras on 2.2.4. I am using Ubuntu 18.10,
installed Keras and tensorflow with Anaconda, and am using multi_processing
to speed up training, but there is usually this same error after the second
or third epoch with training.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/keras-team/keras/issues/11101#issuecomment-438802017,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ApTAUKGJPMpCquOAl7Ehf0acxkabUcctks5uvHllgaJpZM4WeEMW
.

Same error happening with Model.save_weights on a Cray supercomputer. I can't save my models. (Keras 2.0.3, h5py 2.8.0).

Same here!
Keras 2.1.4+ TF 1.10
Solved with reducing the number of workers.

I have encountered the same issue. It occurs only when the last epoch saves the model weights. I believe it is a mutex issue on the OS side where the code tries to read a weight file before it is closed during writing on disk.

Same here!
Keras 2.2.4 + TF 1.12
My model checkpoint is: ModelCheckpoint('model-{epoch:03d}-{val_loss:.2f}.h5', verbose=1, monitor='val_loss', save_best_only=True, mode='auto')
The error appears after few epochs:
OSError: Unable to create file (unable to lock file, errno = 11, error message = 'Resource temporarily unavailable')
Any news on this issue?
Thanks.

I noticed that issue disappears when I set:
workers = multiprocessing.cpu_count() - 1

Hi! I'm using the sklearn.model_selection.GridSearchCV for hyperparameter optimization.
Where I can find the workers property?
Here a piece of code
grid = GridSearchCV(estimator=hp_model, param_grid=param_grid, n_jobs=-1)
checkpoint = ModelCheckpoint('model-{epoch:03d}-{val_loss:.2f}.h5', verbose=1, monitor='val_loss', save_best_only=True, mode='auto')
tensorboard = TensorBoard(log_dir='./Graph', histogram_freq=0,
write_graph=True, write_images=True)
grid_result = grid.fit(X_train, y_train,
validation_data=(X_test, y_test),
callbacks=[checkpoint, tensorboard],
verbose=0)
The ModelCheckpoint throws the exception: OSError: Unable to create file (unable to lock file, errno = 11, error message = 'Resource temporarily unavailable').
Thanks for your response.
Antonio

@apercky Hi, Antonio, although my response is not gonna help you to solve your problem, but I just want to say that in spsancti's response, he was referring to the parameter worker as in model.fit_generator(..., multiprocessing=True, workers=multiprocessing.cpu_count()-1). My inference is that in your case with GridSearchCV constructor, workers is similar to the parameter n_jobs here, but I'm not quite sure if change that will work.

Hi @BruceDai003 and @spsancti, I made some tests, I could noticed that only if I set the n_jobs=1 the GridSearchCV works without any error. So, I can't use it in production research environment.
If I use n_jobs=multiprocessing.cpu_count()-1, the same error appears. So, I think the problem is in keras/engine/saving.py on multi core environment.
I will check with the EarlyStopping(with restore_best_weights=True) as suggested by @small-yellow-duck , which should save the best model only at the end of grid search process. I'll keep you informed.
Thanks at all guys.
Antonio

I'm facing same issue with below libraries:

Keras 2.2.4
tensorflow-gpu 1.12.0
h5py 2.8.0

But if ModelCheckpoint's save_best_only is `False, It has never been occured.

Same here, when cpu_counts is large: to be more specific, when the cpu_counts = 48, this appears, and never appear when cpu_counts = 12
Keras 2.2.4
tensorflow-gpu 1.12.0
h5py 2.8.0

pambros' solution worked for me. Thanks!

@pambros please tell me where to put the export HDF5_USE_FILE_LOCKING=FALSE

Hi, HDF5_USE_FILE_LOCKING is an environment variable. You can put it in your bash script (or batch on windows but without the "export") before to execute your python code.

Hi, I have the same problem. I tried to debug a bit but didn't manage to find where the problem is. For whatever reason the .hdf5 file is not fully closed or a lock related to h5py lib is still on when the callback of the next epoch tries to save again the weights.
Apparently people have problems when using h5py with locks. I found a temporary solution for now and it seems to work. Add in your script this: export HDF5_USE_FILE_LOCKING=FALSE

Does not work for me.

Hello,
I have tested the solution proposed above a.k.a. export HDF5_USE_FILE_LOCKING=FALSE.
It works indeed but in a multiprocessing environment is inherently flawed. As a matter of fact even if Keras (or HDF5) does not trow any error on the save() call it does not work properly due to the LOCK.
If you try to instantiate the model with load_model('model.h5') you will get this error:
 File "h5py/h5o.pyx", line 167, in h5py.h5o.get_info RuntimeError: Can't get info for object (wrong B-tree signature)

That's indeed possible. I was saving only the weights and it was working. However, the problem was not totally solve for me as I experienced deadlock at the end of random update from time to time. I ended up by not using at all HDF5 and wrote a small ModelCheckpoint function to save the weights with pickle instead.
HDF5 seems not totally thread-safe or a bug is hidden somewhere in keras.

I noticed that issue disappears when I set:
workers = multiprocessing.cpu_count() - 1

Does not work for me: Keras 2.1.3, tf 1.2.1

That's indeed possible. I was saving only the weights and it was working. However, the problem was not totally solve for me as I experienced deadlock at the end of random update from time to time. I ended up by not using at all HDF5 and wrote a small ModelCheckpoint function to save the weights with pickle instead.
HDF5 seems not totally thread-safe or a bug is hidden somewhere in keras.

Could you provide us with that function?

Hey, sure. I copied/pasted the ModelCheckpoint class and modified only the saving part.
`
import pickle
MODEL_SAVE_NAME = 0
MODEL_SAVE_WEIGHTS = 1
def save_weight_light(model, filename):
layers = model.layers
pickle_list = []
for layerId in range(len(layers)):
weigths = layers[layerId].get_weights()
pickle_list.append([layers[layerId].name, weigths])
with open(filename, 'wb') as f:
	pickle.dump(pickle_list, f, -1)

def load_weight_light(model, filename):
layers = model.layers
with open(filename, 'rb') as f:
pickle_list = pickle.load(f)
for layerId in range(len(layers)):
	assert(layers[layerId].name == pickle_list[layerId][MODEL_SAVE_NAME])
	layers[layerId].set_weights(pickle_list[layerId][MODEL_SAVE_WEIGHTS])

class ModelCheckpointLight(Callback):
def init(self, filepath, monitor='val_loss', verbose=0,
save_best_only=False,
mode='auto', period=1):
super(ModelCheckpointLight, self).init()
self.monitor = monitor
self.verbose = verbose
self.filepath = filepath
self.save_best_only = save_best_only
self.period = period
self.epochs_since_last_save = 0
	if mode not in ['auto', 'min', 'max']:
		warnings.warn('ModelCheckpointLight mode %s is unknown, '
					  'fallback to auto mode.' % (mode),
					  RuntimeWarning)
		mode = 'auto'

	if mode == 'min':
		self.monitor_op = np.less
		self.best = np.Inf
	elif mode == 'max':
		self.monitor_op = np.greater
		self.best = -np.Inf
	else:
		if 'acc' in self.monitor or self.monitor.startswith('fmeasure'):
			self.monitor_op = np.greater
			self.best = -np.Inf
		else:
			self.monitor_op = np.less
			self.best = np.Inf

def on_epoch_end(self, epoch, logs=None):
	logs = logs or {}
	self.epochs_since_last_save += 1
	if self.epochs_since_last_save >= self.period:
		self.epochs_since_last_save = 0
		filepath = self.filepath.format(epoch=epoch + 1, **logs)
		if self.save_best_only:
			current = logs.get(self.monitor)
			if current is None:
				warnings.warn('Can save best model only with %s available, '
							  'skipping.' % (self.monitor), RuntimeWarning)
			else:
				if self.monitor_op(current, self.best):
					if self.verbose > 0:
						print('\nEpoch %05d: %s improved from %0.5f to %0.5f,'
							  ' saving model to %s'
							  % (epoch + 1, self.monitor, self.best,
								 current, filepath))
					self.best = current
					save_weight_light(self.model, filepath)
				else:
					if self.verbose > 0:
						print('\nEpoch %05d: %s did not improve from %0.5f' %
							  (epoch + 1, self.monitor, self.best))
		else:
			if self.verbose > 0:
				print('\nEpoch %05d: saving model to %s' % (epoch + 1, filepath))
			save_weight_light(self.model, filepath)

`

I got this error and it was because the (target/intermediate) directories weren't created. I had to manually create them and the error went away.

ModelCheckpointLight.txt
Hey, sure. I copied/pasted the ModelCheckpoint class and modified only the saving part.

I tried your workaround for ~10 models now and it works nicely. Great! But how did you intend to load the model? Doing model = pickle.load(modelfile) gives a list of layers. Did you intend to save the model architecture separately, then iterate over the loaded layers and insert them into a dummy model with the correct architecture?

@pambros' workaround unfortunately did not solve the problem for me. I still get the same OSError with this custm ModelCheckpointLight Callback.

In your callstack, do you have the OSError for a hdf5 file or a pickle file? Because if you use ModelCheckpointLight you should not have anymore any hdf5 file. If it is the case that means you still use another checkpoint somewhere else.

@pambros you're right, the OSError didn't occur again. It was another issue.
I havea question though. When using your load_weight_light function I get AssertionErrors without a message:
`AssertionErrorTraceback (most recent call last)
 in ()
98     print '... done'
99     # helper.test_generator()
--> 100     load_weight_light(model, data_root+'models/Konvid/1k/'+ str(helper.model_name)+'_best_weights.h5')
101
102     print('Testing split ' + str(split) + ' of 10 now.')
/home/fh/Research/DeepLearning/video_kutils/model_helper.py in load_weight_light(model, filename)
540
541         for layerId in range(len(layers)):
--> 542                 assert(layers[layerId].name == pickle_list[layerId][MODEL_SAVE_NAME])
543                 layers[layerId].set_weights(pickle_list[layerId][MODEL_SAVE_WEIGHTS])
544
AssertionError: `
Could you guide me what the problem is here? For the first 5 models this worked fine, then here it doesn't. These weights are just the same model trained with a different split?!

So still no real solution?

So still no real solution?

@pambros' solution of the ModelCheckPointLight further up solved the issue for me.

Hi, I solved this issue by using a generic filename:
the example given in keras is:

For example: if filepath is weights.{epoch:02d}-{val_loss:.2f}.hdf5, then the model checkpoints will be saved with the epoch number and the validation loss in the filename.

Make sure though that you have enough space on your harddisk in case the models are very big ;).

yeus solution worked for me

Yeh, this is super frustrating. I've tried all of the above (threads, workers, unique names, saving just once....) All of this fails on my first attempt to save weights (but only to a specific mount).
Having to implement a different checkpoint class to work around this means this is properly broken. Dear Keras devs, I know this one might be hard to reproduce (I think NAS mounts may be a commonality) please believe us. This is a real problem.
I hope you find a good solution.

Hi, I solved this issue by using a generic filename:
the example given in keras is:

For example: if filepath is weights.{epoch:02d}-{val_loss:.2f}.hdf5, then the model checkpoints will be saved with the epoch number and the validation loss in the filename.

Make sure though that you have enough space on your harddisk in case the models are very big ;).

This "solved" it for me. Now I just have the issue with getting many files that I have to wade through, because it doesn't delete the previous file, essentially making the save_best_only=True parameter completely irrelevant.

Same problem here. When I want to load my current model while my training is still going the error appears.

Reinstalling Keras, Tensorflow and h5py didn't solve the issue for me.
use_multiprocessing=False seems to be a solution.
I am using the multi_gpu_model function so I didn't notice any change in performances.

If you want to keep the standard behaviour of the ModelCheckpointer, use this patched version. It simply catches any error during saving and keeps trying to save the model every 5 seconds.
import numpy as np
import warnings
from time import sleep
from keras.callbacks import Callback

class PatchedModelCheckpoint(Callback):
    """Save the model after every epoch.
    `filepath` can contain named formatting options,
    which will be filled with the values of `epoch` and
    keys in `logs` (passed in `on_epoch_end`).
    For example: if `filepath` is `weights.{epoch:02d}-{val_loss:.2f}.hdf5`,
    then the model checkpoints will be saved with the epoch number and
    the validation loss in the filename.
    # Arguments
        filepath: string, path to save the model file.
        monitor: quantity to monitor.
        verbose: verbosity mode, 0 or 1.
        save_best_only: if `save_best_only=True`,
            the latest best model according to
            the quantity monitored will not be overwritten.
        save_weights_only: if True, then only the model's weights will be
            saved (`model.save_weights(filepath)`), else the full model
            is saved (`model.save(filepath)`).
        mode: one of {auto, min, max}.
            If `save_best_only=True`, the decision
            to overwrite the current save file is made
            based on either the maximization or the
            minimization of the monitored quantity. For `val_acc`,
            this should be `max`, for `val_loss` this should
            be `min`, etc. In `auto` mode, the direction is
            automatically inferred from the name of the monitored quantity.
        period: Interval (number of epochs) between checkpoints.
    """

    def __init__(self, filepath, monitor='val_loss', verbose=0,
                 save_best_only=False, save_weights_only=False,
                 mode='auto', period=1):
        super(PatchedModelCheckpoint, self).__init__()
        self.monitor = monitor
        self.verbose = verbose
        self.filepath = filepath
        self.save_best_only = save_best_only
        self.save_weights_only = save_weights_only
        self.period = period
        self.epochs_since_last_save = 0

        if mode not in ['auto', 'min', 'max']:
            warnings.warn('ModelCheckpoint mode %s is unknown, '
                          'fallback to auto mode.' % (mode),
                          RuntimeWarning)
            mode = 'auto'

        if mode == 'min':
            self.monitor_op = np.less
            self.best = np.Inf
        elif mode == 'max':
            self.monitor_op = np.greater
            self.best = -np.Inf
        else:
            if 'acc' in self.monitor or self.monitor.startswith('fmeasure'):
                self.monitor_op = np.greater
                self.best = -np.Inf
            else:
                self.monitor_op = np.less
                self.best = np.Inf

    def on_epoch_end(self, epoch, logs=None):
        logs = logs or {}
        self.epochs_since_last_save += 1
        if self.epochs_since_last_save >= self.period:
            self.epochs_since_last_save = 0
            filepath = self.filepath.format(epoch=epoch + 1, **logs)
            if self.save_best_only:
                current = logs.get(self.monitor)
                if current is None:
                    warnings.warn('Can save best model only with %s available, '
                                  'skipping.' % (self.monitor), RuntimeWarning)
                else:
                    if self.monitor_op(current, self.best):
                        if self.verbose > 0:
                            print('\nEpoch %05d: %s improved from %0.5f to %0.5f,'
                                  ' saving model to %s'
                                  % (epoch + 1, self.monitor, self.best,
                                     current, filepath))
                        self.best = current

                        saved_correctly = False
                        while not saved_correctly:
                            try:
                                if self.save_weights_only:
                                    self.model.save_weights(filepath, overwrite=True)
                                else:
                                    self.model.save(filepath, overwrite=True)
                                saved_correctly = True
                            except Exception as error:
                                print('Error while trying to save the model: {}.\nTrying again...'.format(error))
                                sleep(5)
                    else:
                        if self.verbose > 0:
                            print('\nEpoch %05d: %s did not improve from %0.5f' %
                                  (epoch + 1, self.monitor, self.best))
            else:
                if self.verbose > 0:
                    print('\nEpoch %05d: saving model to %s' % (epoch + 1, filepath))
                saved_correctly = False
                while not saved_correctly:
                    try:
                        if self.save_weights_only:
                            self.model.save_weights(filepath, overwrite=True)
                        else:
                            self.model.save(filepath, overwrite=True)
                        saved_correctly = True
                    except Exception as error:
                        print('Error while trying to save the model: {}.\nTrying again...'.format(error))
                        sleep(5)

I am also facing the same issue.
Versions details:
OS: Ubuntu 16.04
Python: 3.6.8
Keras: 2.2.4
Tensorflow: 1.12.0
h5py: 2.9.0
Setting use_multiprocessing=False for me was not an option because it made training unfeasible in terms of time.
Using EarlyStopping with restore_best_weights=True then saving was also not ideal in my case since I am checkpointing two models, one for 'val_loss' and one for 'val_acc'.
Because of the same reason, I did not wanted to save multiple files with different names because they would occupy too much space.
I created a simpler workaround then @ale152, on which I add a '-temp' substring to the filename being saved by ModelCheckpoint, but I add a Callback that renames the file, removing the '-temp' string from the filename.
class AuxModelCheckpoint(Callback):
    def __init__(self, filepath):
        super(AuxModelCheckpoint, self).__init__()
        self.filepath = filepath

        path, filename = os.path.split(self.filepath)
        new_filename = filename.replace('-temp','')
        new_filepath = os.path.join(path, new_filename)

        self.new_filepath = new_filepath

    def on_epoch_end(self, epoch, logs={}):
        if os.path.exists(self.filepath):
            os.rename(self.filepath, self.new_filepath)

I just encountered, wasted my whole night Tesla T4 GPU😖😖😖

The same problem happen to me as well, in my case, set the number of worker smaller seems work

I have the same problem. Keras 2.2.5, h5py 2.9.0, tensorflow 1.12.0. Still no solution from keras team ?

ran into the same problem. Keras 2.2.4, h5py 2.7.1, tf 1.12.0....

The reason of this error is that only one processing can open .hdf5 file when .hdf5 file is in writing mode. Multi processings visit one .hdf5 file at the same time may raise error. In my case, I want to save save_weights_only, but this error occured.

def save_weights(self, filepath, by_name=False,
                 skip_mismatch=False, reshape=False):
    def open_hdf5( filename, *args, **kwargs):
        while True:
            try:
                file = h5py.File(filename, *args, **kwargs)
                break
            except OSError:
                sleep(1)
        return file
    if h5py is None:
        raise ImportError('`save_weights` requires h5py.')
    # If file exists and should not be overwritten:
    if not overwrite and os.path.isfile(filepath):
        proceed = ask_to_proceed_with_overwrite(filepath)
        if not proceed:
            return
    with open_hdf5(filepath, 'w') as f:
        saving.save_weights_to_hdf5_group(f, self.layers)
        f.flush()

I add a open_hdf5() function to replace h5py.File()
From
with h5py.File(filepath, 'w') as f:
to
with open_hdf5(filepath, 'w') as f:
If the open_hdf5() function found there is a confliction among multi_processing, then use the sleep() to suspend the subsequent processing.
Hoping my experience will help you.

The problem of mine was caused by having a ':' in my h5 file's name, remove ':' and the problem just disappeared.

I had the same problem. It was solved after i removed saved model priviously with same name

Same problem with keras 2.3.1, tensorflow-gpu 2.1.0 and h5py 2.8.0.
Any new solution??

Same issue...
In my case I was running 2 python processes both training models, not sure if this contributed to the issue?

It seems that we need to create all the parent directories before using the ModelCheckpoint callback. It works with tensorflow-gpu 2.1.0 on my machine (Ubuntu 16.04).

ran into same issue on
TensorFlow - 2.2.0
Keras - 2.3.1
Changed code as below to make it work for me :
savefile = "keras/models/model.json" #earlier it was just a folder name "keras/model" checkpoint = keras.callbacks.ModelCheckpoint(savefile, monitor='val_loss', verbose=1,                                              save_best_only=True)

Same problem to me
h5py - 2.10.0
tensorflow -1.14.0
Keras -2.2.4
Reducing work let the training pass through,, however duplicated loss are printed

same issue here
hp5py - 2.10.0
tensorflow-gpu  - 2.0.0
keras - 2.3.0
Is nothing happening to this issue?

h5py - 2.10.0
tensorflow - 1.14.0
Keras - 2.2.4
I got the same issue on my program. I'm relying on this implementation of a DataGenerator https://stanford.edu/~shervine/blog/keras-how-to-generate-data-on-the-fly
The issue happens when the batch_size is set to 1 with num_workers > 1 (I set it to 4), and use_multiprocessing set to True.

I'm using
h5py - 2.10.0
tensorflow - 1.12.0
Keras - 2.2.4
and, just like @MounirB, i also used a similar implementation to what's found on
https://stanford.edu/~shervine/blog/keras-how-to-generate-data-on-the-fly
getting the same error if use_multiprocessing=True and workers>1.
Changing the version of h5py was not an option for me since i'm using virtual dataset (which came in a later version than 2.7.1).
The @bnucaowu solution had worked for me, but i also had to apply the same workaround on H5Dict class from keras.utils.io_utils.py .
Because of this, i like @ale152 's solution more which is easier to use than having to change the code on a third party code.

If you want to keep the standard behaviour of the ModelCheckpointer, use this patched version. It simply catches any error during saving and keeps trying to save the model every 5 seconds.
import numpy as np
import warnings
from time import sleep
from keras.callbacks import Callback

class PatchedModelCheckpoint(Callback):
    """Save the model after every epoch.
    `filepath` can contain named formatting options,
    which will be filled with the values of `epoch` and
    keys in `logs` (passed in `on_epoch_end`).
    For example: if `filepath` is `weights.{epoch:02d}-{val_loss:.2f}.hdf5`,
    then the model checkpoints will be saved with the epoch number and
    the validation loss in the filename.
    # Arguments
        filepath: string, path to save the model file.
        monitor: quantity to monitor.
        verbose: verbosity mode, 0 or 1.
        save_best_only: if `save_best_only=True`,
            the latest best model according to
            the quantity monitored will not be overwritten.
        save_weights_only: if True, then only the model's weights will be
            saved (`model.save_weights(filepath)`), else the full model
            is saved (`model.save(filepath)`).
        mode: one of {auto, min, max}.
            If `save_best_only=True`, the decision
            to overwrite the current save file is made
            based on either the maximization or the
            minimization of the monitored quantity. For `val_acc`,
            this should be `max`, for `val_loss` this should
            be `min`, etc. In `auto` mode, the direction is
            automatically inferred from the name of the monitored quantity.
        period: Interval (number of epochs) between checkpoints.
    """

    def __init__(self, filepath, monitor='val_loss', verbose=0,
                 save_best_only=False, save_weights_only=False,
                 mode='auto', period=1):
        super(PatchedModelCheckpoint, self).__init__()
        self.monitor = monitor
        self.verbose = verbose
        self.filepath = filepath
        self.save_best_only = save_best_only
        self.save_weights_only = save_weights_only
        self.period = period
        self.epochs_since_last_save = 0

        if mode not in ['auto', 'min', 'max']:
            warnings.warn('ModelCheckpoint mode %s is unknown, '
                          'fallback to auto mode.' % (mode),
                          RuntimeWarning)
            mode = 'auto'

        if mode == 'min':
            self.monitor_op = np.less
            self.best = np.Inf
        elif mode == 'max':
            self.monitor_op = np.greater
            self.best = -np.Inf
        else:
            if 'acc' in self.monitor or self.monitor.startswith('fmeasure'):
                self.monitor_op = np.greater
                self.best = -np.Inf
            else:
                self.monitor_op = np.less
                self.best = np.Inf

    def on_epoch_end(self, epoch, logs=None):
        logs = logs or {}
        self.epochs_since_last_save += 1
        if self.epochs_since_last_save >= self.period:
            self.epochs_since_last_save = 0
            filepath = self.filepath.format(epoch=epoch + 1, **logs)
            if self.save_best_only:
                current = logs.get(self.monitor)
                if current is None:
                    warnings.warn('Can save best model only with %s available, '
                                  'skipping.' % (self.monitor), RuntimeWarning)
                else:
                    if self.monitor_op(current, self.best):
                        if self.verbose > 0:
                            print('\nEpoch %05d: %s improved from %0.5f to %0.5f,'
                                  ' saving model to %s'
                                  % (epoch + 1, self.monitor, self.best,
                                     current, filepath))
                        self.best = current

                        saved_correctly = False
                        while not saved_correctly:
                            try:
                                if self.save_weights_only:
                                    self.model.save_weights(filepath, overwrite=True)
                                else:
                                    self.model.save(filepath, overwrite=True)
                                saved_correctly = True
                            except Exception as error:
                                print('Error while trying to save the model: {}.\nTrying again...'.format(error))
                                sleep(5)
                    else:
                        if self.verbose > 0:
                            print('\nEpoch %05d: %s did not improve from %0.5f' %
                                  (epoch + 1, self.monitor, self.best))
            else:
                if self.verbose > 0:
                    print('\nEpoch %05d: saving model to %s' % (epoch + 1, filepath))
                saved_correctly = False
                while not saved_correctly:
                    try:
                        if self.save_weights_only:
                            self.model.save_weights(filepath, overwrite=True)
                        else:
                            self.model.save(filepath, overwrite=True)
                        saved_correctly = True
                    except Exception as error:
                        print('Error while trying to save the model: {}.\nTrying again...'.format(error))
                        sleep(5)

I think @ale152 's reply deserves more attention, it's quite a workaround. Nice work!

I noticed that the bug does not happen if the validation data is not a generator but just a regular tuple of images and labels. Since usually the validation data is fixed and not as large as the training data, maybe somebody could solve the issue in this way.

Hello, I was experiencing this issue and the only way to solve it was adding the following code at the beginning of the file. I found this solution here https://groups.google.com/g/h5py/c/0kgiMVGSTBE
import os
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"


fix: use the full type name for ErrorInfo

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

[x] Make sure to open an issue as a bug/issue before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
[x] Ensure the tests and linter pass
[x] Code coverage does not decrease (if any source code was changed)
[x] Appropriate docs were updated (if necessary)

Fixes #1091 🦕

@googlebot I signed it!

@googlebot I signed it!