I wrote LDA model in notebook.
I'm trying to wrap my gensim LDA model with mallet, getting the following error:
CalledProcessError: Command '../input/mymallet/mallet-2.0.8/bin/mallet import-file --preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input /tmp/fbcc4b_corpus.txt --output /tmp/fbcc4b_corpus.mallet' returned non-zero exit status 126.
The error raised because of the second line:
mallet_path = '../input/mymallet/mallet-2.0.8/bin/mallet' # update this path
ldamallet = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, num_topics=20, id2word=id2word)
The path is correct.
Tried this solution: Gensim mallet CalledProcessError: returned non-zero exit status
didn't work for me..
I spent hours trying to solve it.
Tried this solution and nothing worked.
Looking to a previous sucessfull call I made to LDA Mallet, I noticed some parameters were not being set, then I made it like this:
gensim.models.wrappers.LdaMallet(mallet_path=mallet_path, corpus=corpus, num_topics=num_topics, id2word=id2word, prefix='temp_file_', workers=4)
I really hope it helps you. Finding a solution to this problem is a pain.
I don't know if you ever solved this or not, but I have run into the same problem. For me, the problem occurred because I had uploaded the mallet binary to a research server, where Mallet lost its executable flag. My solution was to run
chmod -R +x mallet-2.0.8
This allowed the gensim wrapper, or whatever means you wish to run mallet, to run the executable file. If you want to be more precise with the chmod, you could probably chmod the actual mallet-2.0.8/bin/mallet file.
Related
We use a linter (for Golang) that run through a Github Actions workflow every time we open or update a Pull Request on our repository.
It recently started to return the following error:
File is not `gofmt`-ed with `-s` (gofmt)
After what happened in this other PR to the file pkg/api/api/go.
(EDIT: link added to evaluate and eventually reproduce the error)
Evidences:
I would like to understand what was the source of this error, as well as how to resolve it?
Source of the error
It seems this error can be returned when the file is not properly formatted according to Go rules.
For example: If you accidentally used tab indentation rather than spaces.
EDIT: blackgreen's answer gives more accurate details about the source of the error
How to resolve it
You can use the following Go command:
gofmt -s -w <path_to_file>.go
... then commit the code.
Note that in my case: gofmt -w pkg/api/api.go was enough to resolve the problem (without the -s flag, which I found strange as the error specifically asked for the -s).
Source 1 + Source 2
The -s flag in gofmt has nothing to do with formatting. It's about simplifying the code:
Try to simplify code (after applying the rewrite rule, if any).
The warning you see comes from the linter golangci-lint. Since you claim to have fixed the error by running gofmt -w, the presence of the hint "with -s" may be due to this bug: https://github.com/golangci/golangci-lint/issues/513.
The linked issue was fixed in 2019 and released with v1.17.0. You might want to check if your pipeline is using an older version.
Assuming that your file pkg/api/api.go triggered the warning just because it was not formatted, gofmt -w solves the issue because -w overwrites the file:
If a file's formatting is different from gofmt's, overwrite it with gofmt's version.
when I run this code in mac:
x_train, y_train = load_svmlight_file("mq2008.train")
I get this error in bash:
-bash: syntax error near unexpected token `('
and if I run it in shell, I face this error:
NameError: name 'load_svmlight_file' is not defined
How can I solve this problem?
Welcome to StackOverflow!
IMO, you have a Python code and trying to replicate its output. If so, you should first load all Python-related imports first. This is what it means to NameError here, Python interpreter is not able to understand what it is, because this function is not part of its existing definitions it has.
If I may suggest, please spend some time to get the hands-on-learning of Python.
I have a chef recipe that looks something like this:
package 'build-essential' do
action :install
end
cmd = Mixlib::ShellOut.new("gcc -dumpversion")
cmd.run_command
gcc_version = cmd.stdout.strip()
If I execute the recipe on a system where gcc is installed, the recipe runs fine without errors. However, if I run the recipe on a system which doesn't have gcc install I get the error 'no such file or directory - gcc'.
I came to know about the chef two-phases stuff when trying to find a solution to my problem. I was expecting the package installation to satisfy the gcc requirement. How can I tell chef that this requirement will be satisfied later and not throw an error at compile time?
I tried the following, but the attribute does not get updated.
Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
ruby_block "gcc_version" do
block do
s = shell_out("gcc -dumpversion")
node.default['gcc_version'] = s.stdout.strip()
end
end
echo "echo #{node[:gcc_version]}" do
command "echo #{node[:gcc_version]}"
end
Any help is appreciated. Thanks.
So okay, a few issues here. First, forget that Chef::Resource::whatever.send(:include trick. Never do it, literally never. In this case, the ShellOut mixin is already available in all the places anyway.
Next, and more importantly, you've still got a two-pass confusion issue. See https://coderanger.net/two-pass/ for details but basically the strings in that echo resource (I assume that said execute originally and you messed up the coping?) get interpolated at compile time. You haven't said what you are trying to do, but you probably need to use the lazy{} helper method.
And last, don't store things in node attributes like that, it's super brittle and hard to work with.
I am using RRDTool to manage and graph my Performance Data.
Currently, I am calling RRDTool from a bash script, but I get an Error, which I can not fix.
My Bash Script looks like this:
# Call RRDTool and save the output
output=$(rrdtool graph --width 4000 \
DEF:data=/usr/local/pnp4nagios/var/perfdata/FM/win_tcpu.rrd:proc:AVERAGE \
VDEF:slope=data,LSLSLOPE \
PRINT:slope:'%lf')
echo "Output: " $output
I am trying to solve for m in y = m*x + b with this simple example.
My Performance Data looks something like this:
<NAGIOS>
<DATASOURCE>
<TEMPLATE>nrpe_win_tcpu</TEMPLATE>
<RRDFILE>/usr/local/pnp4nagios/var/perfdata/FM/win_tcpu.rrd</RRDFILE>
<RRD_STORAGE_TYPE>SINGLE</RRD_STORAGE_TYPE>
<RRD_HEARTBEAT>8460</RRD_HEARTBEAT>
<IS_MULTI>0</IS_MULTI>
<DS>1</DS>
<NAME>proc</NAME>
...
</DATASOURCE>
...
As you can see the file name is correct and the DataSource Name is also correct.
My Problem is that the DEF does not seem to work. I get the following Error Message:
ERROR: Not a valid vname: data in line VDEF:slope=data,LSLSLOPE
When trying to access the data saved in Variable data like this, just to check if the problem is in my VDEF line:
LINE1:data#0000FF:"data" \
I get the following Error:
ERROR: parameter 'data' does not represent a number in line LINE1:data#0000FF:data
This clarifies that the problem is somewhere in the DEF line but I have no clue why this is happening.
Does anybody have an idea why I get these error messages and how to fix this problem?
Any help appreciated. Thanks in advance.
I found the problem. It was only a really dumb mistake I made.
I was calling:
rrdtool graph --width 4000 \
DEF:data=/usr/local/pnp4nagios/var/perfdata/FM/win_tcpu.rrd:proc:AVERAGE \
VDEF:slope=data,LSLSLOPE \
...
Looking in the usage description of RRDTool graph again, showed me this:
rrdtool graph filename [-s|--start seconds] [-e|--end seconds] ...
I was simply missing a filename. When calling it like mentioned above RRDTool interpreted my DEF line as a filename. This would cause an error when writing the result to this file, but RRDTool exits with an error on the VDEF line, since data was never defined.
Thanks for all the comments. I just wanted to clarify some things I tested:
- The variable Name data does not cause any problems
- It is totally working to have a DS with name 1 and you could also access it in a CDEF and so on
Thanks for the help!
You can't do a line of a VDEF - it's a value, and is only valid with an aggregation function.
From: http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html LSLSLOPE is valid.
You should be able to graph data though, e.g.
LINE1:data#00CC00:data
That you can't - and get 'does not represent a number' makes me wonder what's in you data source. I would suggest you have a look at xport to dump the RRD and see what's in there.
You might well be not getting enough input data to build a CDP within your RRD, and so they're all UNKNOWN or NaN.
(Invalid VNAME does make me wonder though - have you tried changing it to something other than data - which seems like it could be a reserved word.)
I'm attempting to install ruby processing. I followed this tutorial:
https://github.com/jashkenas/ruby-processing/wiki/Getting-Started
After I rake ( before I install jruby ), all of the tests fail. I get the following result before every print out and not sure how to fix it.
WARNING: you need to set PROCESSING_ROOT in ~/.rp5rc
Following the tipp by Oscar here is an easy Copy & Paste solution for Mac Users:
echo PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java" > ~/.rp5rc
The instructions on the wiki have been updated since you asked this question.
As is now suggested, you can use this gist to create your .rp5rc file. Create a new sketch in Processing using the contents of SetProcessingRoot.pde in the gist, and it will suggest the correct PROCESSING_ROOT value for your system and create the file. Note that you'll have to delete the default text ("enter your processing root here") and enter the suggested (or another) path.
Or, if you know the correct PROCESSING_ROOT path for your system, do the following:
echo PROCESSING_ROOT: \"correct_path\" > ~/.rp5rc