No Fine-Tune/ Bert_token_embedder module inside Allennlp commands or token_embedders - allennlp

I have been working on a github project from here:
https://github.com/jiacheng-xu/DiscoBERT
According to the authors, it requires Allennlp 0.9.0. I created a virtual environment using pip and tried installing 0.9, but it gave an error. So, I tried Allennlp 1.2 which installed fine,
but I am getting errors in the two following lines:
from allennlp.commands.fine_tune import fine_tune_model_from_file_paths
from allennlp.modules.token_embedders.bert_token_embedder import PretrainedBertModel, PretrainedBertEmbedder
It seems, in the 1.2 version at least, there is no fine_tune and bert_token_embedder module. Is there a quick way to get past these errors?

From https://github.com/allenai/allennlp/issues/4849:
We removed the file_tune command. You can now create your model with the from_archive() constructor (either with code, or from the config file), and train that way.
bert_token_embedder has also gone away. We unified the support for huggingface models in the pretrained_transformer_* classes. So there is now a pretrained_transformer_tokenizer, pretrained_transformer_indexer and a pretrained_transformer_embedder. Before we had several slightly different ways of doing the same thing, and that seemed dangerously confusing.
Why did installing the old version fail though? There is no reason old versions wouldn't work.

Related

How to make docstrings from cythonized module available to Pylance?

I am working on a fully cython compiled python package, using setuptools and some reStructured Text docstrings to generate the pdf documentation using sphinx-autodoc with good success.
The docstrings are not displayed when loading the package in Jupyter Notebooks (using Pylance language server in VSCode). I did not test but suspect that the issue exists in other IDEs or frontends either. Switching to e.g. Jedi as a language server in VSCode did not help.
Using the help(...) command on the routines/classes yields the expected docstring, so the issue does not seem to be with the cython compilation.
There are quite a few issues about formatting issues popping up when searching for Docstrings and Pylance, the issue never seems to be that they simply can not be retrieved.
Since sphinx (autodoc) does not throw any errors and generates a full-package encompassing documentation set fine, this seems a lot like a problem with the language servers to me.
However, I suspect that there may be any compiler directive or setuptools option that I am unaware of that could help - but I do not know about these.
I do have
compiler_directives={'embedsignature': True}
in the setup.py and since the docstrings do show up when using help(..), I do not think this is an issue.
I have also added
import Cython.Compiler.Options
Cython.Compiler.Options.docstrings = True
even though that is indicated as being the default, and it did not change the behavior at all.
Scavenging through the options of Pylance in VSCode was unfruitful, too - I did not expect much there anyways, since obviously the display of the docstrings does work for plenty (all?) other packages that I looked at. Everything is on defaults.

Cannot resolve module 'json'

I'm dealing with a very weird issue. For some reason, since a few days, my application doesn't seem to be loading JSON files anymore inside modules.
The app was created with create-react-app, and has been in development for a while without any issues. I've had a dependency in the project (world-countries) that basically only exports a json file. This dependency is not a recent addition.
So, here's the thing. From one day to another, I get the following error while starting/building the app:
Module not found: Error: Cannot resolve module 'json' in /Users/…
As far as I know, I made no changes that would result in this, and create-react-app's webpack version is still the same.
Requiring a random JSON file in the root of my app goes well, somehow this odd behaviour only seems to apply to json files within node_modules in the app.
Some other points:
By this point, I have reinstalled dependencies and node.js multiple times, checked file permissions, etc. To no avail.
Another dependency that also used a json file internally also had this issue, but I managed to circumvent that.
I've explicitly installed json-loader in case something with webpack got messed up, but this didn't make any difference. In fact, I find it curious that _the missing dependency is "json" and not json-loader.
I have a feeling that this is a weird issue caused by some file limit, as when I run the dev server, I get errors relating to too many open files. My project isn't that big, so this seems weird, and I have a feeling it might have something to do with some npm linked modules I have, but there is no recursion or anything.
I'm still quite perplexed, and have no idea what the issue might be. Any suggestions on how to fix this are very welcome
Some people seemed to have had a related issue regarding importing json files in the past. It wasn't in a dependency but I believe it is related.
I took the time to scaffold a new project, import the world-countries modules and log it, and it was working fine.
I would recommend you to update re-scaffold or update all your dependencies, but most notably react-scripts which is version 0.9.5 for me. My create-react-app-version is also 1.3.0.

Linking to specific glibc version in Cython

I have a Cython extension which I've compiled on Ubuntu 14 and uploaded as an Anaconda package. I'm trying to install the package on another machine which is running Scientific Linux (6?) which ships with an older version of glibc. When I try to import the module I get an error that looks (something like) this:
./myprogram: /lib/libc.so.6: version `GLIBC_2.14' not found (required by ./myprogram)
When I say "something like" - the "myprogram" is actually the .so name of the extension.
From what I understand this error is because I have a newer version of glibc on the build system which has an updated version of the memcpy function.
This page has a good description of the problem, and some rather impractical solutions: http://www.lightofdawn.org/wiki/wiki.cgi/NewAppsOnOldGlibc
There is also a much simpler answer proposed here: How can I link to a specific glibc version?
My question is: how to I apply this solution to my Cython extension? Assuming the __asm__ solution works (as given in the second link) what's the best way to get it into the C generated by Cython?
Also, more generally, how to other modules avoid this issue in the first place? For example, I installed and ran a pre-built copy of numpy without any issues.
This turned out to be quite simple.
Create the following header, glibc_fix.h:
__asm__(".symver memcpy,memcpy#GLIBC_2.2.5")
Then include it by using CFLAGS="-include glibc_fix.h". This can be set as an environment variable, or defined in setup.py.
Additionally, it turns out numpy doesn't do anything special in this regard. if I compile it myself it links with the newer version on my system.

How to import directory in libsass

I am trying to import several SCSS files(page1.scss, page2.scss and ..) in my app.scss but I haven't found any solution(plugin and etc).
I saw these answers but they are for Ruby on Rails not libsass. I am using:
Gulp,
Gulp-sass,
Libsass and
Laravel Elixir
Any solution?
Long answer short:
As you can find in this issue in the official libsass project github, globs are not part of SASS specification, so there are no plans to support them in libsass.
why?
The main concern about implementing this feature is related with the order importing the files. In first place, AFAIK there isn't a standard way on how reading stream files behave in different OSs (linux, mac os x, windows) or filesystems (reiserfs, ext3, ntfs, fat32, etc.), what leads to a unpredictable ordering while importing the files.
Anyway, even if there will be some sort of cross-platform standard support to read files from every filesystem and you are sure you are always gonna get the files in the same order. Which order should it be?.
if you still need/want it:
Still there are some hack-y ways you can achieve this behaviour but I will strongly recommend to avoid them and follow the official recommendations.
There is a ruby gem: sass-globbing. But it doesn't works with gulp/libsass because of the different way they handle files streams. Inspired on this ruby-gem there is gulp-css-globbing. It looks like this project is a bit outdated, but you can use it on your own risk.
And in this blog post: Sass Directory Imports With Gulp, you can find another solution that involve automatically creating a file per folder that imports all files inside. A bit convoluted for my taste but it will work if you really need this.

Pyro.Naming.NameServerStarter documentation

I'd like to use Pyro.Naming.NameServerStarter.start() but I can't find any documentation, and it is better than 'pyro-ns'.
I also don't know why y can't retrieve Pyro4 module since I've just updated Pyro modules. Only Pyro module is reacheable, so I can't even try Pyro4.naming.startNS()
Sounds like you're stuck with the old, unmaintained, version 3 of Pyro. Upgrade your library to Pyro4 first.
The shell command pyro4-ns is just that; it starts a name server from the shell. Using the API to do it is a different thing because then it is your own code that starts it.
Documentation on how to do that is available here: http://pythonhosted.org/Pyro4/nameserver.html#starting-the-name-server-from-within-your-own-code