jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.88k stars 260 forks source link

Emacs hangs after a while #709

Open dsaard opened 8 years ago

dsaard commented 8 years ago

Hi there, i´m new to elpy and my emacs hangs after a while.

beginning to type "import argp" works with a tooltip and completion and then no more ...

after writing some lines more emacs hangs completly

strace the emacs process:

[pid 27335] recvmsg(8, 0x7ffd1bfa2490, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] poll([{fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=11, events=POLLIN}, {fd=5, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27335] write(15, "{\"id\":36,\"method\":\"get_calltip\","..., 1683) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] pselect6(17, [5 7 8 11 13 16], [], NULL, {0, 19999226}, {NULL, 8}) = 0 (Timeout)
[pid 27335] recvmsg(8, 0x7ffd1bfa2490, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] poll([{fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=11, events=POLLIN}, {fd=5, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27335] write(15, "{\"id\":36,\"method\":\"get_calltip\","..., 1683) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] pselect6(17, [5 7 8 11 13 16], [], NULL, {0, 19999313}, {NULL, 8}) = 1 (in [8], left {0, 1735472})
[pid 27335] --- SIGIO {si_signo=SIGIO, si_code=SI_KERNEL} ---
[pid 27335] rt_sigreturn()              = 1
[pid 27335] recvmsg(8, {msg_name(0)=NULL, msg_iov(1)=[{"U\2\31\210\3277\313\7\3\4\4\0\0\0\0\0\0\0\0\4\4\4\4\4\0\0\3\37%\2\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
[pid 27335] recvmsg(8, 0x7ffd1bfa2490, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] poll([{fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=11, events=POLLIN}, {fd=5, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27335] recvmsg(8, 0x7ffd1bfa2490, 0) = -1 EAGAIN (Resource temporarily unavailable)

with C+ggg emacs comes back and hangs again C+gggg M+x elpy-rpc-restart and i can write some lines

First i thought with the oh-my-emacs config collection is sometthig wrong, but some behavior with a plain setup

My versions:

Elpy Configuration
Virtualenv........: None
RPC Python........: 2.7.9 (/usr/bin/python)
Interactive Python: ipython (/usr/bin/ipython)
Emacs.............: 24.4.1
Elpy..............: 1.10.0
Jedi..............: 0.9.0
Rope..............: 0.10.3
Importmagic.......: 0.1.3
Autopep8..........: 0.1.3
Syntax checker....: flake8 (/usr/local/bin/flake8)

i checked the related issues but with no success ...

any ideas?

Cheers

Dominik

Nicholas-Autio-Mitchell commented 6 years ago

@jorgenschaefer I have upgraded Jedi to 0.11. It does not solve the problem. I can reliably reproduce the issue (shown in my screenshot above) by running two separate files/buffers interatively into only python interpreter (I use iPython). Is this a known limitation?

jorgenschaefer commented 6 years ago

I do not understand what you mean with "running two separate files/buffers interactively into only python interpreter" – what exactly are you doing to reproduce this issue?

samuelnair commented 6 years ago

I was noticing a similar slow down, but it would happen regularly only when i loaded a python file. After a bit of searching, i was able to fix it by ensuring ido did not use tramp by adding the following lines to my startup.

(custom-set-variables
                '(ido-enable-tramp-completion nil))

Additionally, you can try disabling tramp altogether

(setq tramp-mode nil)
Nicholas-Autio-Mitchell commented 6 years ago

Thanks for the input! It is now with my current work a relevant concern.

Maybe I don't know/understand everything I need to about tramp, but I was always working locally (never on remote machines), back when I reported this problem. Am I missing something?

On Fri, 13 Apr 2018, 17:08 Samuel Nair, notifications@github.com wrote:

I was noticing a similar slow down, but it would happen regularly only when i loaded a python file. After a bit of searching, i was able to fix it by ensuring ido did not use tramp by adding the following lines to my startup.

(custom-set-variables '(ido-enable-tramp-completion nil))

Additionally, you can try disabling tramp altogether

(setq tramp-mode nil)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jorgenschaefer/elpy/issues/709#issuecomment-381165956, or mute the thread https://github.com/notifications/unsubscribe-auth/AMOhpYKUXV4NRjTW-v-biCaDP6mhCIrbks5toL9wgaJpZM4GeO7g .

samuelnair commented 6 years ago

Did my fix work for you ?

I noticed the slowdown was primarily due to the ssh connection spawned by Tramp, which i suspected ido was interacting with. Once i disabled ido from using tramp, it was back to being fast.

Btw, i was always working on local files too, even then i noticed the weird ssh connections that tramp does.

Nicholas-Autio-Mitchell commented 6 years ago

Apologies, I was unclear. I had this problem while working locally. At some point (maybe with an update from Elpy or elsewhere (perhaps Jedi, as Jorgen suggested), I stopped having the issue. Recently I started working with Tramp quite a lot and I am still not really having the problem. I did not deactivate anything, as per your suggestion.

One other point to clarify (answering a question Jorgen asked me in DEcember - oops): I could reproduce the error when I was send parts of >= 2 scripts to the ipython interactive shell (using C-c C-c and the like).

Now I have been using the same methods as well as this new functionality, and have not been having any issues.

adamliter commented 4 years ago

I'm having this issue, too. It started recently, and it is making elpy (and Emacs) unusable. Emacs will regularly lock up for 45 seconds or more. Looking at htop output, it does look like the elpy process starts using >=90% of the CPU. Here's the output from having toggled toggle-debug-on-quit from one (of the many) times that this happens to me:

Debugger entered--Lisp error: (quit)
  process-send-string(#<process  *elpy-rpc [project:~/projects/ling723_course_project/gulordava_etal2018/src/ environment:/Users/adamliter/.pyenv/versions/greenRNNs]*> #("{\"id\":555,\"method\":\"get_completions\",\"params\":[\"/Users/adamliter/projects/ling723_course_project/gulordava_etal2018/src/get_moses_metrics.py\",\"import argparse\\nimport torch\\nimport logging\\nimport torch.nn.functional as F\\nimport numpy as np\\nimport pandas as pd\\nfrom pathlib import Path\\n\\nfrom dictionary_corpus import Dictionary\\n\\nlogger = logging.getLogger('get_moses_metrics')\\nlogger.setLevel(logging.DEBUG)\\n\\nformatter = logging.Formatter(\\n    '%(levelname)s (%(asctime)s): %(message)s'\\n)\\n\\nch = logging.StreamHandler()\\nch.setLevel(logging.DEBUG)\\nch.setFormatter(formatter)\\n\\nfh = logging.FileHandler(\\n    'get_moses_metrics.log'\\n)\\nfh.setLevel(logging.DEBUG)\\nfh.setFormatter(formatter)\\n\\nlogger.addHandler(ch)\\nlogger.addHandler(fh)\\n\\nparser = argparse.ArgumentParser(description='Extracts metrics for correlational analysis')\\n\\nparser.add_argument('--vocab_dir', type=str,\\n                    help='Directory containing vocab.txt')\\nparser.add_argument('--model', type=str,\\n                    help='Path to trained model to use')\\nparser.add_argument('--stims', type=str,\\n                    help='Path to CSV file containing Moses Illusion stimuli')\\nparser.add_argument('--cuda', action='store_true',\\n                    help='Use CUDA')\\n\\nargs = parser.parse_args()\\n\\n\\nclass Moses(object):\\n    def __init__(self, model_path, vocab_dir, stims, cuda):\\n        self.cuda = cuda\\n        try:\\n            with open(model_path, 'rb') as f:\\n                if cuda:\\n                    self.model = torch.load(f)\\n                else:\\n                    self.model = torch.load(f, map_location=torch.device('cpu'))\\n                    logging.info('Successfully loaded model.')\\n        except FileNotFoundError:\\n            logging.error('Model not found on disk.')\\n\\n        self.dictionary = Dictionary(vocab_dir)\\n        logging.info('Successfully loaded model vocaulary.')\\n\\n        self.stims = pd.read_csv(stims)\\n        logging.info('Successfully loaded Moses Illusion stimuli.')\\n        self.stims.Context.replace(r'(\\\\w*)(,)', r'\\\\1 \\\\2', regex=True, inplace=True)\\n        logging.info('Successfully separated comma from word in Moses Illusion stimuli.')\\n        self.stims.Context.replace(r'(\\\\w)(\\\\?)', r'\\\\1 \\\\2 <eos>', regex=True, inplace=True)\\n        logging.info('Successfully replaced \\\"WORD?\\\" with \\\"WORD ? <eos>\\\".')\\n        self.stims['Prefix'] = self.stims.Context.replace(r'XXX.*', '', regex=True)\\n        logging.info('Successfully created item prefixes for extracting model metrics.')\\n        self.stims['IntendedSentence'] = self.stims.apply(\\n            lambda x: x.Context.replace('XXX', x['valid']), axis=1)\\n        logging.info('Successfully assembled intended sentence for extracting model metrics.')\\n        self.stims['SubstitutedSentence'] = self.stims.apply(\\n            lambda x: x.Context.replace('XXX', x['invalid']), axis=1)\\n        logging.info('Successfully assembled substituted sentence for extracting model metrics.')\\n\\n\\n    def get_metrics(self):\\n        for i in range(0, len(self.stims)):\\n            prefix_words = self.stims[i].Prefix.split()\\n            intended_sent_words = self.stims[i].IntendedSentence\\n            substitued_sent = self.stims[i].SubstitutedSentence\\n\\n            \\n\\n#if __name__ == \\\"__main__\\\":\\n\",2951]}\n" 143 149 (fontified t face font-lock-keyword-face) 149 158 (fontified t) 160 166 (fontified t face font-lock-keyword-face) 166 172 (fontified t) 174 180 (fontified t face font-lock-keyword-face) 180 188 (fontified t) 190 196 (fontified t face font-lock-keyword-face) 196 217 (fontified t) 217 219 (fontified t face font-lock-keyword-face) 219 221 (fontified t) 223 229 (fontified t face font-lock-keyword-face) 229 236 (fontified t) 236 238 (fontified t face font-lock-keyword-face) 238 241 (fontified t) 243 249 (fontified t face font-lock-keyword-face) 249 257 (fontified t) 257 259 (fontified t face font-lock-keyword-face) 259 262 (fontified t) 264 268 (fontified t face font-lock-keyword-face) 268 277 (fontified t) 277 283 (fontified t face font-lock-keyword-face) 283 288 (fontified t) 292 296 (fontified t face font-lock-keyword-face) 296 315 (fontified t) 315 321 (fontified t face font-lock-keyword-face) 321 332 (fontified t) 336 342 (fontified t face font-lock-variable-name-face) 342 363 (fontified t) 363 364 (fontified t syntax-table (15) face font-lock-string-face) 364 381 (fontified t face font-lock-string-face) 381 382 (fontified t syntax-table (15) face font-lock-string-face) 382 383 (fontified t) 385 392 (fontified t) 392 415 (fontified t) 419 428 (fontified t face font-lock-variable-name-face) 428 429 (fontified t) 429 449 (fontified t) 451 455 (fontified t) 455 456 (fontified t syntax-table (15) face font-lock-string-face) 456 496 (fontified t face font-lock-string-face) 496 497 (fontified t syntax-table (15) face font-lock-string-face) 499 500 (fontified t) 504 506 (fontified t face font-lock-variable-name-face) 506 517 (fontified t) 517 532 (fontified t) 534 537 (fontified t) 537 560 (fontified t) 562 565 (fontified t) 565 578 (fontified t) 578 588 (fontified t) 592 594 (fontified t face font-lock-variable-name-face) 594 605 (fontified t) 605 617 (fontified t) 619 623 (fontified t) 623 624 (fontified t syntax-table (15) face font-lock-string-face) 624 645 (fontified t face font-lock-string-face) 645 646 (fontified t syntax-table (15) face font-lock-string-face) 648 649 (fontified t) 651 654 (fontified t) 654 677 (fontified t) 679 682 (fontified t) 682 695 (fontified t) 695 705 (fontified t) 709 716 (fontified t) 716 730 (fontified t) 732 739 (fontified t) 739 753 (fontified t) 757 763 (fontified t face font-lock-variable-name-face) 763 802 (fontified t) 802 803 (syntax-table (15) fontified t face font-lock-string-face) 803 820 (fontified t face font-lock-string-face) 820 823 (fontified t face font-lock-string-face) 823 846 (fontified t face font-lock-string-face) 846 847 (syntax-table (15) fontified t face font-lock-string-face) 847 848 (fontified t) 852 872 (fontified t) 872 873 (syntax-table (15) fontified t face font-lock-string-face) 873 884 (fontified t face font-lock-string-face) 884 885 (syntax-table (15) fontified t face font-lock-string-face) 885 887 (fontified t) 887 891 (fontified t face font-lock-builtin-face) 891 892 (fontified t) 892 895 (fontified t face font-lock-builtin-face) 895 896 (fontified t) 898 918 (fontified t) 918 922 (fontified t face font-lock-builtin-face) 922 923 (fontified t) 923 924 (syntax-table (15) fontified t face font-lock-string-face) 924 954 (fontified t face font-lock-string-face) 954 955 (syntax-table (15) fontified t face font-lock-string-face) 955 956 (fontified t) 958 978 (fontified t) 978 979 (syntax-table (15) fontified t face font-lock-string-face) 979 986 (fontified t face font-lock-string-face) 986 987 (syntax-table (15) fontified t face font-lock-string-face) 987 989 (fontified t) 989 993 (fontified t face font-lock-builtin-face) 993 994 (fontified t) 994 997 (fontified t face font-lock-builtin-face) 997 998 (fontified t) 1000 1020 (fontified t) 1020 1024 (fontified t face font-lock-builtin-face) 1024 1025 (fontified t) 1025 1026 (syntax-table (15) fontified t face font-lock-string-face) 1026 1054 (fontified t face font-lock-string-face) 1054 1055 (syntax-table (15) fontified t face font-lock-string-face) 1055 1056 (fontified t) 1058 1078 (fontified t) 1078 1079 (syntax-table (15) fontified t face font-lock-string-face) 1079 1086 (fontified t face font-lock-string-face) 1086 1087 (syntax-table (15) fontified t face font-lock-string-face) 1087 1089 (fontified t) 1089 1093 (fontified t face font-lock-builtin-face) 1093 1094 (fontified t) 1094 1097 (fontified t face font-lock-builtin-face) 1097 1098 (fontified t) 1100 1104 (fontified t) 1104 1120 (fontified t) 1120 1124 (fontified t face font-lock-builtin-face) 1124 1125 (fontified t) 1125 1126 (syntax-table (15) fontified t face font-lock-string-face) 1126 1138 (fontified t face font-lock-string-face) 1138 1142 (fontified t face font-lock-string-face) 1142 1162 (fontified t face font-lock-string-face) 1162 1176 (face font-lock-string-face fontified t) 1176 1177 (syntax-table (15) face font-lock-string-face fontified t) 1177 1178 (fontified t) 1180 1200 (fontified t) 1200 1201 (fontified t syntax-table (15) face font-lock-string-face) 1201 1207 (fontified t face font-lock-string-face) 1207 1208 (fontified t syntax-table (15) face font-lock-string-face) 1208 1217 (fontified t) 1217 1218 (fontified t syntax-table (15) face font-lock-string-face) 1218 1221 (fontified t face font-lock-string-face) 1221 1228 (fontified t face font-lock-string-face) 1228 1229 (fontified t syntax-table (15) face font-lock-string-face) 1229 1230 (fontified t) 1232 1234 (fontified t) 1234 1252 (fontified t) 1252 1256 (fontified t face font-lock-builtin-face) 1256 1257 (fontified t) 1257 1258 (fontified t syntax-table (15) face font-lock-string-face) 1258 1265 (fontified t face font-lock-string-face) 1265 1266 (fontified t face font-lock-string-face) 1266 1267 (fontified t syntax-table (15) face font-lock-string-face) 1267 1268 (fontified t) 1272 1276 (fontified t face font-lock-variable-name-face) 1276 1298 (fontified t) 1304 1309 (fontified t face font-lock-keyword-face) 1309 1310 (fontified t) 1310 1315 (fontified t face font-lock-type-face) 1315 1316 (fontified t) 1316 1322 (fontified t face font-lock-builtin-face) 1322 1324 (fontified t) 1326 1330 (fontified t) 1330 1333 (fontified t face font-lock-keyword-face) 1333 1334 (fontified t) 1334 1342 (fontified t face font-lock-function-name-face) 1342 1343 (fontified t) 1343 1347 (fontified t face font-lock-keyword-face) 1347 1385 (fontified t) 1387 1395 (fontified t) 1395 1399 (fontified t face font-lock-keyword-face) 1399 1411 (fontified t) 1413 1421 (fontified t) 1421 1424 (fontified t face font-lock-keyword-face) 1424 1425 (fontified t) 1427 1439 (fontified t) 1439 1443 (fontified t face font-lock-keyword-face) 1443 1444 (fontified t) 1444 1448 (fontified t face font-lock-builtin-face) 1448 1461 (fontified t) 1461 1462 (fontified t syntax-table (15) face font-lock-string-face) 1462 1464 (fontified t face font-lock-string-face) 1464 1465 (fontified t syntax-table (15) face font-lock-string-face) 1465 1467 (fontified t) 1467 1469 (fontified t face font-lock-keyword-face) 1469 1472 (fontified t) 1474 1490 (fontified t) 1490 1492 (fontified t face font-lock-keyword-face) 1492 1498 (fontified t) 1500 1520 (fontified t) 1520 1524 (fontified t face font-lock-keyword-face) 1524 1546 (fontified t) 1548 1564 (fontified t) 1564 1568 (fontified t face font-lock-keyword-face) 1568 1569 (fontified t) 1571 1591 (fontified t) 1591 1595 (fontified t face font-lock-keyword-face) 1595 1644 (fontified t) 1644 1645 (fontified t syntax-table (15) face font-lock-string-face) 1645 1648 (fontified t face font-lock-string-face) 1648 1649 (fontified t syntax-table (15) face font-lock-string-face) 1649 1651 (fontified t) 1653 1686 (fontified t) 1686 1687 (fontified t syntax-table (15) face font-lock-string-face) 1687 1695 (fontified t face font-lock-string-face) 1695 1713 (face font-lock-string-face fontified t) 1713 1714 (syntax-table (15) face font-lock-string-face fontified t) 1714 1715 (fontified t) 1717 1725 (fontified t) 1725 1731 (fontified t face font-lock-keyword-face) 1731 1732 (fontified t) 1732 1747 (fontified t face font-lock-type-face) 1747 1749 (fontified t face font-lock-type-face) 1749 1750 (fontified t) 1752 1778 (fontified t) 1778 1779 (syntax-table (15) fontified t face font-lock-string-face) 1779 1785 (fontified t face font-lock-string-face) 1785 1788 (fontified t face font-lock-string-face) 1788 1803 (fontified t face font-lock-string-face) 1803 1804 (syntax-table (15) fontified t face font-lock-string-face) 1804 1805 (fontified t) 1809 1816 (fontified t) 1816 1817 (fontified t) 1817 1821 (fontified t face font-lock-keyword-face) 1821 1856 (fontified t) 1858 1874 (fontified t) 1874 1879 (fontified t) 1879 1880 (fontified t syntax-table (15) face font-lock-string-face) 1880 1916 (fontified t face font-lock-string-face) 1916 1917 (fontified t syntax-table (15) face font-lock-string-face) 1917 1918 (fontified t) 1922 1930 (fontified t) 1930 1934 (fontified t face font-lock-keyword-face) 1934 1961 (fontified t) 1963 1979 (fontified t) 1979 1984 (fontified t) 1984 1985 (fontified t syntax-table (15) face font-lock-string-face) 1985 2028 (fontified t face font-lock-string-face) 2028 2029 (fontified t syntax-table (15) face font-lock-string-face) 2029 2030 (fontified t) 2032 2040 (fontified t) 2040 2044 (fontified t face font-lock-keyword-face) 2044 2068 (fontified t) 2068 2069 (fontified t syntax-table (15) face font-lock-string-face) 2069 2070 (fontified t face font-lock-string-face) 2072 2078 (fontified t face font-lock-string-face) 2078 2079 (fontified t syntax-table (15) face font-lock-string-face) 2079 2082 (fontified t) 2082 2083 (fontified t syntax-table (15) face font-lock-string-face) 2085 2087 (fontified t face font-lock-string-face) 2089 2090 (fontified t face font-lock-string-face) 2090 2091 (fontified t syntax-table (15) face font-lock-string-face) 2091 2099 (fontified t) 2099 2103 (fontified t face font-lock-constant-face) 2103 2105 (fontified t) 2105 2113 (fontified t) 2113 2117 (fontified t face font-lock-constant-face) 2117 2118 (fontified t) 2120 2136 (fontified t) 2136 2141 (fontified t) 2141 2142 (fontified t syntax-table (15) face font-lock-string-face) 2142 2199 (fontified t face font-lock-string-face) 2199 2207 (fontified t face font-lock-string-face) 2207 2208 (fontified t syntax-table (15) face font-lock-string-face) 2208 2209 (fontified t) 2211 2219 (fontified t) 2219 2223 (fontified t face font-lock-keyword-face) 2223 2247 (fontified t) 2247 2248 (fontified t syntax-table (15) face font-lock-string-face) 2248 2249 (fontified t face font-lock-string-face) 2251 2254 (fontified t face font-lock-string-face) 2256 2258 (fontified t face font-lock-string-face) 2258 2259 (fontified t syntax-table (15) face font-lock-string-face) 2259 2262 (fontified t) 2262 2263 (fontified t syntax-table (15) face font-lock-string-face) 2265 2267 (fontified t face font-lock-string-face) 2269 2276 (fontified t face font-lock-string-face) 2276 2277 (fontified t syntax-table (15) face font-lock-string-face) 2277 2285 (fontified t) 2285 2289 (fontified t face font-lock-constant-face) 2289 2299 (fontified t) 2299 2303 (fontified t face font-lock-constant-face) 2303 2304 (fontified t) 2306 2327 (fontified t) 2327 2328 (fontified t syntax-table (15) face font-lock-string-face) 2328 2350 (fontified t face font-lock-string-face) 2352 2356 (fontified t face font-lock-string-face) 2356 2357 (fontified t face font-lock-string-face) 2359 2365 (fontified t face font-lock-string-face) 2367 2371 (fontified t face font-lock-string-face) 2371 2372 (fontified t face font-lock-string-face) 2372 2379 (fontified t face font-lock-string-face) 2381 2382 (fontified t face font-lock-string-face) 2382 2383 (fontified t syntax-table (15) face font-lock-string-face) 2383 2384 (fontified t) 2386 2394 (fontified t) 2394 2398 (fontified t face font-lock-keyword-face) 2398 2405 (fontified t) 2405 2406 (fontified t syntax-table (15) face font-lock-string-face) 2406 2412 (fontified t face font-lock-string-face) 2412 2413 (fontified t syntax-table (15) face font-lock-string-face) 2413 2417 (fontified t) 2417 2421 (fontified t face font-lock-keyword-face) 2421 2445 (fontified t) 2445 2446 (fontified t syntax-table (15) face font-lock-string-face) 2446 2451 (fontified t face font-lock-string-face) 2451 2452 (fontified t syntax-table (15) face font-lock-string-face) 2452 2454 (fontified t) 2454 2455 (fontified t syntax-table (15) face font-lock-string-face) 2455 2456 (fontified t syntax-table (15) face font-lock-string-face) 2456 2464 (fontified t) 2464 2468 (fontified t face font-lock-constant-face) 2468 2469 (fontified t) 2471 2487 (fontified t) 2487 2492 (fontified t) 2492 2493 (fontified t syntax-table (15) face font-lock-string-face) 2493 2557 (fontified t face font-lock-string-face) 2557 2558 (fontified t syntax-table (15) face font-lock-string-face) 2558 2559 (fontified t) 2561 2569 (fontified t) 2569 2573 (fontified t face font-lock-keyword-face) 2573 2580 (fontified t) 2580 2581 (syntax-table (15) fontified t face font-lock-string-face) 2581 2597 (fontified t face font-lock-string-face) 2597 2598 (syntax-table (15) fontified t face font-lock-string-face) 2598 2602 (fontified t) 2602 2606 (fontified t face font-lock-keyword-face) 2606 2613 (fontified t) 2613 2618 (fontified t face font-lock-builtin-face) 2618 2619 (fontified t) 2621 2626 (fontified t) 2626 2633 (fontified t) 2633 2639 (fontified t face font-lock-keyword-face) 2639 2660 (fontified t) 2660 2661 (fontified t) 2661 2662 (fontified t syntax-table (15) face font-lock-string-face) 2662 2665 (fontified t face font-lock-string-face) 2665 2666 (fontified t syntax-table (15) face font-lock-string-face) 2666 2670 (fontified t) 2670 2671 (fontified t syntax-table (15) face font-lock-string-face) 2671 2676 (fontified t face font-lock-string-face) 2676 2677 (fontified t syntax-table (15) face font-lock-string-face) 2677 2688 (fontified t) 2690 2706 (fontified t) 2706 2711 (fontified t) 2711 2712 (fontified t syntax-table (15) face font-lock-string-face) 2712 2782 (fontified t face font-lock-string-face) 2782 2783 (fontified t syntax-table (15) face font-lock-string-face) 2783 2784 (fontified t) 2786 2794 (fontified t) 2794 2798 (fontified t face font-lock-keyword-face) 2798 2805 (fontified t) 2805 2806 (syntax-table (15) fontified t face font-lock-string-face) 2806 2807 (fontified t face font-lock-string-face) 2807 2811 (fontified t face font-lock-string-face) 2811 2825 (fontified t face font-lock-string-face) 2825 2826 (syntax-table (15) fontified t face font-lock-string-face) 2826 2830 (fontified t) 2830 2834 (fontified t face font-lock-keyword-face) 2834 2841 (fontified t) 2841 2846 (fontified t face font-lock-builtin-face) 2846 2847 (fontified t) 2849 2861 (fontified t) 2861 2867 (fontified t face font-lock-keyword-face) 2867 2889 (fontified t) 2889 2890 (fontified t syntax-table (15) face font-lock-string-face) 2890 2893 (fontified t face font-lock-string-face) 2893 2894 (fontified t syntax-table (15) face font-lock-string-face) 2894 2898 (fontified t) 2898 2899 (fontified t syntax-table (15) face font-lock-string-face) 2899 2902 (fontified t face font-lock-string-face) 2902 2906 (fontified t face font-lock-string-face) 2906 2907 (fontified t syntax-table (15) face font-lock-string-face) 2907 2918 (fontified t) 2920 2928 (fontified t) 2928 2936 (fontified t) 2936 2941 (fontified t) 2941 2942 (fontified t syntax-table (15) face font-lock-string-face) 2942 2977 (fontified t face font-lock-string-face) 2977 2978 (fontified t face font-lock-string-face) 2978 3015 (fontified t face font-lock-string-face) 3015 3016 (fontified t syntax-table (15) face font-lock-string-face) 3016 3017 (fontified t rear-nonsticky t) 3023 3027 (fontified t) 3027 3030 (fontified t face font-lock-keyword-face) 3030 3031 (fontified t) 3031 3042 (fontified t face font-lock-function-name-face) 3042 3043 (fontified t) 3043 3047 (fontified t face font-lock-keyword-face) 3047 3049 (fontified t) 3051 3059 (fontified t) 3059 3062 (fontified t face font-lock-keyword-face) 3062 3065 (fontified t) 3065 3067 (fontified t face font-lock-keyword-face) 3067 3068 (fontified t) 3068 3073 (fontified t face font-lock-builtin-face) 3073 3074 (fontified t) 3074 3077 (fontified t) 3077 3080 (fontified t face font-lock-builtin-face) 3080 3081 (fontified t) 3081 3085 (fontified t face font-lock-keyword-face) 3085 3091 (fontified t) 3091 3092 (fontified t) 3092 3093 (fontified t) 3093 3094 (fontified t) 3096 3108 (fontified t) 3108 3114 (fontified t face font-lock-variable-name-face) 3114 3120 (fontified t ws-butler-chg chg face font-lock-variable-name-face) 3120 3123 (fontified t) 3123 3127 (fontified t face font-lock-keyword-face) 3127 3143 (fontified t) 3143 3151 (fontified t ws-butler-chg chg) 3153 3165 (fontified t) 3165 3178 (fontified t face font-lock-variable-name-face) 3178 3184 (fontified t ws-butler-chg chg face font-lock-variable-name-face) 3184 3187 (fontified t) 3187 3191 (fontified t face font-lock-keyword-face) 3191 3217 (fontified t) 3219 3231 (fontified t) 3231 3246 (fontified t face font-lock-variable-name-face) 3246 3249 (fontified t) 3249 3253 (fontified t face font-lock-keyword-face) 3253 3273 (fontified t) 3273 3274 (ws-butler-chg chg fontified t) 3274 3282 (fontified t) 3286 3298 (ws-butler-chg chg fontified t) 3302 3303 (fontified t face font-lock-comment-delimiter-face) 3303 3318 (fontified t face font-lock-comment-face) 3320 3328 (fontified t face font-lock-comment-face) 3330 3331 (fontified t face font-lock-comment-face)))
  elpy-rpc--call("get_completions" ("/Users/adamliter/projects/ling723_course_project/gulordava_etal2018/src/get_moses_metrics.py" #("import argparse\nimport torch\nimport logging\nimport torch.nn.functional as F\nimport numpy as np\nimport pandas as pd\nfrom pathlib import Path\n\nfrom dictionary_corpus import Dictionary\n\nlogger = logging.getLogger('get_moses_metrics')\nlogger.setLevel(logging.DEBUG)\n\nformatter = logging.Formatter(\n    '%(levelname)s (%(asctime)s): %(message)s'\n)\n\nch = logging.StreamHandler()\nch.setLevel(logging.DEBUG)\nch.setFormatter(formatter)\n\nfh = logging.FileHandler(\n    'get_moses_metrics.log'\n)\nfh.setLevel(logging.DEBUG)\nfh.setFormatter(formatter)\n\nlogger.addHandler(ch)\nlogger.addHandler(fh)\n\nparser = argparse.ArgumentParser(description='Extracts metrics for correlational analysis')\n\nparser.add_argument('--vocab_dir', type=str,\n                    help='Directory containing vocab.txt')\nparser.add_argument('--model', type=str,\n                    help='Path to trained model to use')\nparser.add_argument('--stims', type=str,\n                    help='Path to CSV file containing Moses Illusion stimuli')\nparser.add_argument('--cuda', action='store_true',\n                    help='Use CUDA')\n\nargs = parser.parse_args()\n\n\nclass Moses(object):\n    def __init__(self, model_path, vocab_dir, stims, cuda):\n        self.cuda = cuda\n        try:\n            with open(model_path, 'rb') as f:\n                if cuda:\n                    self.model = torch.load(f)\n                else:\n                    self.model = torch.load(f, map_location=torch.device('cpu'))\n                    logging.info('Successfully loaded model.')\n        except FileNotFoundError:\n            logging.error('Model not found on disk.')\n\n        self.dictionary = Dictionary(vocab_dir)\n        logging.info('Successfully loaded model vocaulary.')\n\n        self.stims = pd.read_csv(stims)\n        logging.info('Successfully loaded Moses Illusion stimuli.')\n        self.stims.Context.replace(r'(\\w*)(,)', r'\\1 \\2', regex=True, inplace=True)\n        logging.info('Successfully separated comma from word in Moses Illusion stimuli.')\n        self.stims.Context.replace(r'(\\w)(\\?)', r'\\1 \\2 <eos>', regex=True, inplace=True)\n        logging.info('Successfully replaced \"WORD?\" with \"WORD ? <eos>\".')\n        self.stims['Prefix'] = self.stims.Context.replace(r'XXX.*', '', regex=True)\n        logging.info('Successfully created item prefixes for extracting model metrics.')\n        self.stims['IntendedSentence'] = self.stims.apply(\n            lambda x: x.Context.replace('XXX', x['valid']), axis=1)\n        logging.info('Successfully assembled intended sentence for extracting model metrics.')\n        self.stims['SubstitutedSentence'] = self.stims.apply(\n            lambda x: x.Context.replace('XXX', x['invalid']), axis=1)\n        logging.info('Successfully assembled substituted sentence for extracting model metrics.')\n\n\n    def get_metrics(self):\n        for i in range(0, len(self.stims)):\n            prefix_words = self.stims[i].Prefix.split()\n            intended_sent_words = self.stims[i].IntendedSentence\n            substitued_sent = self.stims[i].SubstitutedSentence\n\n            \n\n#if __name__ == \"__main__\":\n" 0 6 (fontified t face font-lock-keyword-face) 6 16 (fontified t) 16 22 (fontified t face font-lock-keyword-face) 22 29 (fontified t) 29 35 (fontified t face font-lock-keyword-face) 35 44 (fontified t) 44 50 (fontified t face font-lock-keyword-face) 50 71 (fontified t) 71 73 (fontified t face font-lock-keyword-face) 73 76 (fontified t) 76 82 (fontified t face font-lock-keyword-face) 82 89 (fontified t) 89 91 (fontified t face font-lock-keyword-face) 91 95 (fontified t) 95 101 (fontified t face font-lock-keyword-face) 101 109 (fontified t) 109 111 (fontified t face font-lock-keyword-face) 111 115 (fontified t) 115 119 (fontified t face font-lock-keyword-face) 119 128 (fontified t) 128 134 (fontified t face font-lock-keyword-face) 134 139 (fontified t) 139 140 (fontified t) 140 141 (fontified t) 141 145 (fontified t face font-lock-keyword-face) 145 164 (fontified t) 164 170 (fontified t face font-lock-keyword-face) 170 182 (fontified t) 182 183 (fontified t) 183 189 (fontified t face font-lock-variable-name-face) 189 210 (fontified t) 210 211 (fontified t syntax-table (15) face font-lock-string-face) 211 228 (fontified t face font-lock-string-face) 228 229 (fontified t syntax-table (15) face font-lock-string-face) 229 231 (fontified t) 231 238 (fontified t) 238 262 (fontified t) 262 263 (fontified t) 263 272 (fontified t face font-lock-variable-name-face) 272 273 (fontified t) 273 294 (fontified t) 294 298 (fontified t) 298 299 (fontified t syntax-table (15) face font-lock-string-face) 299 339 (fontified t face font-lock-string-face) 339 340 (fontified t syntax-table (15) face font-lock-string-face) 340 341 (fontified t) 341 342 (fontified t) 342 343 (fontified t) 343 344 (fontified t) 344 346 (fontified t face font-lock-variable-name-face) 346 357 (fontified t) 357 373 (fontified t) 373 376 (fontified t) 376 400 (fontified t) 400 403 (fontified t) 403 416 (fontified t) 416 427 (fontified t) 427 428 (fontified t) 428 430 (fontified t face font-lock-variable-name-face) 430 441 (fontified t) 441 454 (fontified t) 454 458 (fontified t) 458 459 (fontified t syntax-table (15) face font-lock-string-face) 459 480 (fontified t face font-lock-string-face) 480 481 (fontified t syntax-table (15) face font-lock-string-face) 481 482 (fontified t) 482 483 (fontified t) 483 484 (fontified t) 484 487 (fontified t) 487 511 (fontified t) 511 514 (fontified t) 514 527 (fontified t) 527 538 (fontified t) 538 539 (fontified t) 539 546 (fontified t) 546 561 (fontified t) 561 568 (fontified t) 568 582 (fontified t) 582 583 (fontified t) 583 584 (fontified t) 584 590 (fontified t face font-lock-variable-name-face) 590 629 (fontified t) 629 630 (syntax-table (15) fontified t face font-lock-string-face) 630 647 (fontified t face font-lock-string-face) 647 650 (fontified t face font-lock-string-face) 650 673 (fontified t face font-lock-string-face) 673 674 (syntax-table (15) fontified t face font-lock-string-face) 674 697 (fontified t) 697 698 (syntax-table (15) fontified t face font-lock-string-face) 698 709 (fontified t face font-lock-string-face) 709 710 (syntax-table (15) fontified t face font-lock-string-face) 710 712 (fontified t) 712 716 (fontified t face font-lock-builtin-face) 716 717 (fontified t) 717 720 (fontified t face font-lock-builtin-face) 720 742 (fontified t) 742 746 (fontified t face font-lock-builtin-face) 746 747 (fontified t) 747 748 (syntax-table (15) fontified t face font-lock-string-face) 748 778 (fontified t face font-lock-string-face) 778 779 (syntax-table (15) fontified t face font-lock-string-face) 779 801 (fontified t) 801 802 (syntax-table (15) fontified t face font-lock-string-face) 802 809 (fontified t face font-lock-string-face) 809 810 (syntax-table (15) fontified t face font-lock-string-face) 810 812 (fontified t) 812 816 (fontified t face font-lock-builtin-face) 816 817 (fontified t) 817 820 (fontified t face font-lock-builtin-face) 820 842 (fontified t) 842 846 (fontified t face font-lock-builtin-face) 846 847 (fontified t) 847 848 (syntax-table (15) fontified t face font-lock-string-face) 848 876 (fontified t face font-lock-string-face) 876 877 (syntax-table (15) fontified t face font-lock-string-face) 877 899 (fontified t) 899 900 (syntax-table (15) fontified t face font-lock-string-face) 900 907 (fontified t face font-lock-string-face) 907 908 (syntax-table (15) fontified t face font-lock-string-face) 908 910 (fontified t) 910 914 (fontified t face font-lock-builtin-face) 914 915 (fontified t) 915 918 (fontified t face font-lock-builtin-face) 918 924 (fontified t) 924 940 (fontified t) 940 944 (fontified t face font-lock-builtin-face) 944 945 (fontified t) 945 946 (syntax-table (15) fontified t face font-lock-string-face) 946 958 (fontified t face font-lock-string-face) 958 962 (fontified t face font-lock-string-face) 962 982 (fontified t face font-lock-string-face) 982 996 (face font-lock-string-face fontified t) 996 997 (syntax-table (15) face font-lock-string-face fontified t) 997 999 (fontified t) 999 1019 (fontified t) 1019 1020 (fontified t syntax-table (15) face font-lock-string-face) 1020 1026 (fontified t face font-lock-string-face) 1026 1027 (fontified t syntax-table (15) face font-lock-string-face) 1027 1036 (fontified t) 1036 1037 (fontified t syntax-table (15) face font-lock-string-face) 1037 1040 (fontified t face font-lock-string-face) 1040 1047 (fontified t face font-lock-string-face) 1047 1048 (fontified t syntax-table (15) face font-lock-string-face) 1048 1050 (fontified t) 1050 1052 (fontified t) 1052 1070 (fontified t) 1070 1074 (fontified t face font-lock-builtin-face) 1074 1075 (fontified t) 1075 1076 (fontified t syntax-table (15) face font-lock-string-face) 1076 1083 (fontified t face font-lock-string-face) 1083 1084 (fontified t face font-lock-string-face) 1084 1085 (fontified t syntax-table (15) face font-lock-string-face) 1085 1087 (fontified t) 1087 1088 (fontified t) 1088 1092 (fontified t face font-lock-variable-name-face) 1092 1116 (fontified t) 1116 1117 (fontified t) 1117 1122 (fontified t face font-lock-keyword-face) 1122 1123 (fontified t) 1123 1128 (fontified t face font-lock-type-face) 1128 1129 (fontified t) 1129 1135 (fontified t face font-lock-builtin-face) 1135 1142 (fontified t) 1142 1145 (fontified t face font-lock-keyword-face) 1145 1146 (fontified t) 1146 1154 (fontified t face font-lock-function-name-face) 1154 1155 (fontified t) 1155 1159 (fontified t face font-lock-keyword-face) 1159 1206 (fontified t) 1206 1210 (fontified t face font-lock-keyword-face) 1210 1231 (fontified t) 1231 1234 (fontified t face font-lock-keyword-face) 1234 1248 (fontified t) 1248 1252 (fontified t face font-lock-keyword-face) 1252 1253 (fontified t) 1253 1257 (fontified t face font-lock-builtin-face) 1257 1270 (fontified t) 1270 1271 (fontified t syntax-table (15) face font-lock-string-face) 1271 1273 (fontified t face font-lock-string-face) 1273 1274 (fontified t syntax-table (15) face font-lock-string-face) 1274 1276 (fontified t) 1276 1278 (fontified t face font-lock-keyword-face) 1278 1282 (fontified t) 1282 1298 (fontified t) 1298 1300 (fontified t face font-lock-keyword-face) 1300 1327 (fontified t) 1327 1331 (fontified t face font-lock-keyword-face) 1331 1370 (fontified t) 1370 1374 (fontified t face font-lock-keyword-face) 1374 1396 (fontified t) 1396 1400 (fontified t face font-lock-keyword-face) 1400 1449 (fontified t) 1449 1450 (fontified t syntax-table (15) face font-lock-string-face) 1450 1453 (fontified t face font-lock-string-face) 1453 1454 (fontified t syntax-table (15) face font-lock-string-face) 1454 1490 (fontified t) 1490 1491 (fontified t syntax-table (15) face font-lock-string-face) 1491 1499 (fontified t face font-lock-string-face) 1499 1517 (face font-lock-string-face fontified t) 1517 1518 (syntax-table (15) face font-lock-string-face fontified t) 1518 1520 (fontified t) 1520 1528 (fontified t) 1528 1534 (fontified t face font-lock-keyword-face) 1534 1535 (fontified t) 1535 1550 (fontified t face font-lock-type-face) 1550 1552 (fontified t face font-lock-type-face) 1552 1554 (fontified t) 1554 1580 (fontified t) 1580 1581 (syntax-table (15) fontified t face font-lock-string-face) 1581 1587 (fontified t face font-lock-string-face) 1587 1590 (fontified t face font-lock-string-face) 1590 1605 (fontified t face font-lock-string-face) 1605 1606 (syntax-table (15) fontified t face font-lock-string-face) 1606 1608 (fontified t) 1608 1609 (fontified t) 1609 1616 (fontified t) 1616 1617 (fontified t) 1617 1621 (fontified t face font-lock-keyword-face) 1621 1656 (fontified t) 1656 1657 (fontified t) 1657 1673 (fontified t) 1673 1678 (fontified t) 1678 1679 (fontified t syntax-table (15) face font-lock-string-face) 1679 1715 (fontified t face font-lock-string-face) 1715 1716 (fontified t syntax-table (15) face font-lock-string-face) 1716 1717 (fontified t) 1717 1718 (fontified t) 1718 1719 (fontified t) 1719 1727 (fontified t) 1727 1731 (fontified t face font-lock-keyword-face) 1731 1758 (fontified t) 1758 1759 (fontified t) 1759 1775 (fontified t) 1775 1780 (fontified t) 1780 1781 (fontified t syntax-table (15) face font-lock-string-face) 1781 1824 (fontified t face font-lock-string-face) 1824 1825 (fontified t syntax-table (15) face font-lock-string-face) 1825 1826 (fontified t) 1826 1827 (fontified t) 1827 1835 (fontified t) 1835 1839 (fontified t face font-lock-keyword-face) 1839 1863 (fontified t) 1863 1864 (fontified t syntax-table (15) face font-lock-string-face) 1864 1872 (fontified t face font-lock-string-face) 1872 1873 (fontified t syntax-table (15) face font-lock-string-face) 1873 1876 (fontified t) 1876 1877 (fontified t syntax-table (15) face font-lock-string-face) 1877 1882 (fontified t face font-lock-string-face) 1882 1883 (fontified t syntax-table (15) face font-lock-string-face) 1883 1891 (fontified t) 1891 1895 (fontified t face font-lock-constant-face) 1895 1897 (fontified t) 1897 1905 (fontified t) 1905 1909 (fontified t face font-lock-constant-face) 1909 1910 (fontified t) 1910 1911 (fontified t) 1911 1927 (fontified t) 1927 1932 (fontified t) 1932 1933 (fontified t syntax-table (15) face font-lock-string-face) 1933 1990 (fontified t face font-lock-string-face) 1990 1998 (fontified t face font-lock-string-face) 1998 1999 (fontified t syntax-table (15) face font-lock-string-face) 1999 2000 (fontified t) 2000 2001 (fontified t) 2001 2009 (fontified t) 2009 2013 (fontified t face font-lock-keyword-face) 2013 2037 (fontified t) 2037 2038 (fontified t syntax-table (15) face font-lock-string-face) 2038 2046 (fontified t face font-lock-string-face) 2046 2047 (fontified t syntax-table (15) face font-lock-string-face) 2047 2050 (fontified t) 2050 2051 (fontified t syntax-table (15) face font-lock-string-face) 2051 2062 (fontified t face font-lock-string-face) 2062 2063 (fontified t syntax-table (15) face font-lock-string-face) 2063 2071 (fontified t) 2071 2075 (fontified t face font-lock-constant-face) 2075 2085 (fontified t) 2085 2089 (fontified t face font-lock-constant-face) 2089 2090 (fontified t) 2090 2091 (fontified t) 2091 2112 (fontified t) 2112 2113 (fontified t syntax-table (15) face font-lock-string-face) 2113 2140 (fontified t face font-lock-string-face) 2140 2141 (fontified t face font-lock-string-face) 2141 2153 (fontified t face font-lock-string-face) 2153 2154 (fontified t face font-lock-string-face) 2154 2163 (fontified t face font-lock-string-face) 2163 2164 (fontified t syntax-table (15) face font-lock-string-face) 2164 2165 (fontified t) 2165 2166 (fontified t) 2166 2174 (fontified t) 2174 2178 (fontified t face font-lock-keyword-face) 2178 2185 (fontified t) 2185 2186 (fontified t syntax-table (15) face font-lock-string-face) 2186 2192 (fontified t face font-lock-string-face) 2192 2193 (fontified t syntax-table (15) face font-lock-string-face) 2193 2197 (fontified t) 2197 2201 (fontified t face font-lock-keyword-face) 2201 2225 (fontified t) 2225 2226 (fontified t syntax-table (15) face font-lock-string-face) 2226 2231 (fontified t face font-lock-string-face) 2231 2232 (fontified t syntax-table (15) face font-lock-string-face) 2232 2234 (fontified t) 2234 2235 (fontified t syntax-table (15) face font-lock-string-face) 2235 2236 (fontified t syntax-table (15) face font-lock-string-face) 2236 2244 (fontified t) 2244 2248 (fontified t face font-lock-constant-face) 2248 2249 (fontified t) 2249 2250 (fontified t) 2250 2266 (fontified t) 2266 2271 (fontified t) 2271 2272 (fontified t syntax-table (15) face font-lock-string-face) 2272 2336 (fontified t face font-lock-string-face) 2336 2337 (fontified t syntax-table (15) face font-lock-string-face) 2337 2338 (fontified t) 2338 2339 (fontified t) 2339 2347 (fontified t) 2347 2351 (fontified t face font-lock-keyword-face) 2351 2358 (fontified t) 2358 2359 (syntax-table (15) fontified t face font-lock-string-face) 2359 2375 (fontified t face font-lock-string-face) 2375 2376 (syntax-table (15) fontified t face font-lock-string-face) 2376 2380 (fontified t) 2380 2384 (fontified t face font-lock-keyword-face) 2384 2391 (fontified t) 2391 2396 (fontified t face font-lock-builtin-face) 2396 2398 (fontified t) 2398 2403 (fontified t) 2403 2410 (fontified t) 2410 2416 (fontified t face font-lock-keyword-face) 2416 2437 (fontified t) 2437 2438 (fontified t) 2438 2439 (fontified t syntax-table (15) face font-lock-string-face) 2439 2442 (fontified t face font-lock-string-face) 2442 2443 (fontified t syntax-table (15) face font-lock-string-face) 2443 2447 (fontified t) 2447 2448 (fontified t syntax-table (15) face font-lock-string-face) 2448 2453 (fontified t face font-lock-string-face) 2453 2454 (fontified t syntax-table (15) face font-lock-string-face) 2454 2465 (fontified t) 2465 2466 (fontified t) 2466 2482 (fontified t) 2482 2487 (fontified t) 2487 2488 (fontified t syntax-table (15) face font-lock-string-face) 2488 2558 (fontified t face font-lock-string-face) 2558 2559 (fontified t syntax-table (15) face font-lock-string-face) 2559 2560 (fontified t) 2560 2561 (fontified t) 2561 2569 (fontified t) 2569 2573 (fontified t face font-lock-keyword-face) 2573 2580 (fontified t) 2580 2581 (syntax-table (15) fontified t face font-lock-string-face) 2581 2582 (fontified t face font-lock-string-face) 2582 2586 (fontified t face font-lock-string-face) 2586 2600 (fontified t face font-lock-string-face) 2600 2601 (syntax-table (15) fontified t face font-lock-string-face) 2601 2605 (fontified t) 2605 2609 (fontified t face font-lock-keyword-face) 2609 2616 (fontified t) 2616 2621 (fontified t face font-lock-builtin-face) 2621 2623 (fontified t) 2623 2635 (fontified t) 2635 2641 (fontified t face font-lock-keyword-face) 2641 2663 (fontified t) 2663 2664 (fontified t syntax-table (15) face font-lock-string-face) 2664 2667 (fontified t face font-lock-string-face) 2667 2668 (fontified t syntax-table (15) face font-lock-string-face) 2668 2672 (fontified t) 2672 2673 (fontified t syntax-table (15) face font-lock-string-face) 2673 2676 (fontified t face font-lock-string-face) 2676 2680 (fontified t face font-lock-string-face) 2680 2681 (fontified t syntax-table (15) face font-lock-string-face) 2681 2692 (fontified t) 2692 2693 (fontified t) 2693 2701 (fontified t) 2701 2709 (fontified t) 2709 2714 (fontified t) 2714 2715 (fontified t syntax-table (15) face font-lock-string-face) 2715 2750 (fontified t face font-lock-string-face) 2750 2751 (fontified t face font-lock-string-face) 2751 2788 (fontified t face font-lock-string-face) 2788 2789 (fontified t syntax-table (15) face font-lock-string-face) 2789 2790 (fontified t rear-nonsticky t) 2790 2791 (fontified t) 2791 2792 (fontified t) 2792 2793 (fontified t) 2793 2797 (fontified t) 2797 2800 (fontified t face font-lock-keyword-face) 2800 2801 (fontified t) 2801 2812 (fontified t face font-lock-function-name-face) 2812 2813 (fontified t) 2813 2817 (fontified t face font-lock-keyword-face) 2817 2820 (fontified t) 2820 2828 (fontified t) 2828 2831 (fontified t face font-lock-keyword-face) 2831 2834 (fontified t) 2834 2836 (fontified t face font-lock-keyword-face) 2836 2837 (fontified t) 2837 2842 (fontified t face font-lock-builtin-face) 2842 2843 (fontified t) 2843 2846 (fontified t) 2846 2849 (fontified t face font-lock-builtin-face) 2849 2850 (fontified t) 2850 2854 (fontified t face font-lock-keyword-face) 2854 2860 (fontified t) 2860 2861 (fontified t) 2861 2862 (fontified t) 2862 2864 (fontified t) 2864 2876 (fontified t) 2876 2882 (fontified t face font-lock-variable-name-face) 2882 2888 (fontified t ws-butler-chg chg face font-lock-variable-name-face) 2888 2891 (fontified t) 2891 2895 (fontified t face font-lock-keyword-face) 2895 2911 (fontified t) 2911 2919 (fontified t ws-butler-chg chg) 2919 2920 (fontified t) 2920 2932 (fontified t) 2932 2945 (fontified t face font-lock-variable-name-face) 2945 2951 (fontified t ws-butler-chg chg face font-lock-variable-name-face) 2951 2954 (fontified t) 2954 2958 (fontified t face font-lock-keyword-face) 2958 2985 (fontified t) 2985 2997 (fontified t) 2997 3012 (fontified t face font-lock-variable-name-face) 3012 3015 (fontified t) 3015 3019 (fontified t face font-lock-keyword-face) 3019 3039 (fontified t) 3039 3040 (ws-butler-chg chg fontified t) 3040 3048 (fontified t) 3048 3049 (ws-butler-chg chg fontified t) 3049 3050 (ws-butler-chg delete fontified t) 3050 3062 (ws-butler-chg chg fontified t) 3062 3063 (fontified t) 3063 3064 (fontified t) 3064 3065 (fontified t face font-lock-comment-delimiter-face) 3065 3080 (fontified t face font-lock-comment-face) 3080 3081 (fontified t face font-lock-comment-face syntax-table (15)) 3081 3089 (fontified t face font-lock-comment-face) 3089 3090 (fontified t face font-lock-comment-face syntax-table (15)) 3090 3092 (fontified t face font-lock-comment-face)) 2951) #f(compiled-function (result) #<bytecode 0x4ab4b011>) elpy-rpc--default-error-callback)
  elpy-rpc("get_completions" ("/Users/adamliter/projects/ling723_course_project/gulordava_etal2018/src/get_moses_metrics.py" #("import argparse\nimport torch\nimport logging\nimport torch.nn.functional as F\nimport numpy as np\nimport pandas as pd\nfrom pathlib import Path\n\nfrom dictionary_corpus import Dictionary\n\nlogger = logging.getLogger('get_moses_metrics')\nlogger.setLevel(logging.DEBUG)\n\nformatter = logging.Formatter(\n    '%(levelname)s (%(asctime)s): %(message)s'\n)\n\nch = logging.StreamHandler()\nch.setLevel(logging.DEBUG)\nch.setFormatter(formatter)\n\nfh = logging.FileHandler(\n    'get_moses_metrics.log'\n)\nfh.setLevel(logging.DEBUG)\nfh.setFormatter(formatter)\n\nlogger.addHandler(ch)\nlogger.addHandler(fh)\n\nparser = argparse.ArgumentParser(description='Extracts metrics for correlational analysis')\n\nparser.add_argument('--vocab_dir', type=str,\n                    help='Directory containing vocab.txt')\nparser.add_argument('--model', type=str,\n                    help='Path to trained model to use')\nparser.add_argument('--stims', type=str,\n                    help='Path to CSV file containing Moses Illusion stimuli')\nparser.add_argument('--cuda', action='store_true',\n                    help='Use CUDA')\n\nargs = parser.parse_args()\n\n\nclass Moses(object):\n    def __init__(self, model_path, vocab_dir, stims, cuda):\n        self.cuda = cuda\n        try:\n            with open(model_path, 'rb') as f:\n                if cuda:\n                    self.model = torch.load(f)\n                else:\n                    self.model = torch.load(f, map_location=torch.device('cpu'))\n                    logging.info('Successfully loaded model.')\n        except FileNotFoundError:\n            logging.error('Model not found on disk.')\n\n        self.dictionary = Dictionary(vocab_dir)\n        logging.info('Successfully loaded model vocaulary.')\n\n        self.stims = pd.read_csv(stims)\n        logging.info('Successfully loaded Moses Illusion stimuli.')\n        self.stims.Context.replace(r'(\\w*)(,)', r'\\1 \\2', regex=True, inplace=True)\n        logging.info('Successfully separated comma from word in Moses Illusion stimuli.')\n        self.stims.Context.replace(r'(\\w)(\\?)', r'\\1 \\2 <eos>', regex=True, inplace=True)\n        logging.info('Successfully replaced \"WORD?\" with \"WORD ? <eos>\".')\n        self.stims['Prefix'] = self.stims.Context.replace(r'XXX.*', '', regex=True)\n        logging.info('Successfully created item prefixes for extracting model metrics.')\n        self.stims['IntendedSentence'] = self.stims.apply(\n            lambda x: x.Context.replace('XXX', x['valid']), axis=1)\n        logging.info('Successfully assembled intended sentence for extracting model metrics.')\n        self.stims['SubstitutedSentence'] = self.stims.apply(\n            lambda x: x.Context.replace('XXX', x['invalid']), axis=1)\n        logging.info('Successfully assembled substituted sentence for extracting model metrics.')\n\n\n    def get_metrics(self):\n        for i in range(0, len(self.stims)):\n            prefix_words = self.stims[i].Prefix.split()\n            intended_sent_words = self.stims[i].IntendedSentence\n            substitued_sent = self.stims[i].SubstitutedSentence\n\n            \n\n#if __name__ == \"__main__\":\n" 0 6 (fontified t face font-lock-keyword-face) 6 16 (fontified t) 16 22 (fontified t face font-lock-keyword-face) 22 29 (fontified t) 29 35 (fontified t face font-lock-keyword-face) 35 44 (fontified t) 44 50 (fontified t face font-lock-keyword-face) 50 71 (fontified t) 71 73 (fontified t face font-lock-keyword-face) 73 76 (fontified t) 76 82 (fontified t face font-lock-keyword-face) 82 89 (fontified t) 89 91 (fontified t face font-lock-keyword-face) 91 95 (fontified t) 95 101 (fontified t face font-lock-keyword-face) 101 109 (fontified t) 109 111 (fontified t face font-lock-keyword-face) 111 115 (fontified t) 115 119 (fontified t face font-lock-keyword-face) 119 128 (fontified t) 128 134 (fontified t face font-lock-keyword-face) 134 139 (fontified t) 139 140 (fontified t) 140 141 (fontified t) 141 145 (fontified t face font-lock-keyword-face) 145 164 (fontified t) 164 170 (fontified t face font-lock-keyword-face) 170 182 (fontified t) 182 183 (fontified t) 183 189 (fontified t face font-lock-variable-name-face) 189 210 (fontified t) 210 211 (fontified t syntax-table (15) face font-lock-string-face) 211 228 (fontified t face font-lock-string-face) 228 229 (fontified t syntax-table (15) face font-lock-string-face) 229 231 (fontified t) 231 238 (fontified t) 238 262 (fontified t) 262 263 (fontified t) 263 272 (fontified t face font-lock-variable-name-face) 272 273 (fontified t) 273 294 (fontified t) 294 298 (fontified t) 298 299 (fontified t syntax-table (15) face font-lock-string-face) 299 339 (fontified t face font-lock-string-face) 339 340 (fontified t syntax-table (15) face font-lock-string-face) 340 341 (fontified t) 341 342 (fontified t) 342 343 (fontified t) 343 344 (fontified t) 344 346 (fontified t face font-lock-variable-name-face) 346 357 (fontified t) 357 373 (fontified t) 373 376 (fontified t) 376 400 (fontified t) 400 403 (fontified t) 403 416 (fontified t) 416 427 (fontified t) 427 428 (fontified t) 428 430 (fontified t face font-lock-variable-name-face) 430 441 (fontified t) 441 454 (fontified t) 454 458 (fontified t) 458 459 (fontified t syntax-table (15) face font-lock-string-face) 459 480 (fontified t face font-lock-string-face) 480 481 (fontified t syntax-table (15) face font-lock-string-face) 481 482 (fontified t) 482 483 (fontified t) 483 484 (fontified t) 484 487 (fontified t) 487 511 (fontified t) 511 514 (fontified t) 514 527 (fontified t) 527 538 (fontified t) 538 539 (fontified t) 539 546 (fontified t) 546 561 (fontified t) 561 568 (fontified t) 568 582 (fontified t) 582 583 (fontified t) 583 584 (fontified t) 584 590 (fontified t face font-lock-variable-name-face) 590 629 (fontified t) 629 630 (syntax-table (15) fontified t face font-lock-string-face) 630 647 (fontified t face font-lock-string-face) 647 650 (fontified t face font-lock-string-face) 650 673 (fontified t face font-lock-string-face) 673 674 (syntax-table (15) fontified t face font-lock-string-face) 674 697 (fontified t) 697 698 (syntax-table (15) fontified t face font-lock-string-face) 698 709 (fontified t face font-lock-string-face) 709 710 (syntax-table (15) fontified t face font-lock-string-face) 710 712 (fontified t) 712 716 (fontified t face font-lock-builtin-face) 716 717 (fontified t) 717 720 (fontified t face font-lock-builtin-face) 720 742 (fontified t) 742 746 (fontified t face font-lock-builtin-face) 746 747 (fontified t) 747 748 (syntax-table (15) fontified t face font-lock-string-face) 748 778 (fontified t face font-lock-string-face) 778 779 (syntax-table (15) fontified t face font-lock-string-face) 779 801 (fontified t) 801 802 (syntax-table (15) fontified t face font-lock-string-face) 802 809 (fontified t face font-lock-string-face) 809 810 (syntax-table (15) fontified t face font-lock-string-face) 810 812 (fontified t) 812 816 (fontified t face font-lock-builtin-face) 816 817 (fontified t) 817 820 (fontified t face font-lock-builtin-face) 820 842 (fontified t) 842 846 (fontified t face font-lock-builtin-face) 846 847 (fontified t) 847 848 (syntax-table (15) fontified t face font-lock-string-face) 848 876 (fontified t face font-lock-string-face) 876 877 (syntax-table (15) fontified t face font-lock-string-face) 877 899 (fontified t) 899 900 (syntax-table (15) fontified t face font-lock-string-face) 900 907 (fontified t face font-lock-string-face) 907 908 (syntax-table (15) fontified t face font-lock-string-face) 908 910 (fontified t) 910 914 (fontified t face font-lock-builtin-face) 914 915 (fontified t) 915 918 (fontified t face font-lock-builtin-face) 918 924 (fontified t) 924 940 (fontified t) 940 944 (fontified t face font-lock-builtin-face) 944 945 (fontified t) 945 946 (syntax-table (15) fontified t face font-lock-string-face) 946 958 (fontified t face font-lock-string-face) 958 962 (fontified t face font-lock-string-face) 962 982 (fontified t face font-lock-string-face) 982 996 (face font-lock-string-face fontified t) 996 997 (syntax-table (15) face font-lock-string-face fontified t) 997 999 (fontified t) 999 1019 (fontified t) 1019 1020 (fontified t syntax-table (15) face font-lock-string-face) 1020 1026 (fontified t face font-lock-string-face) 1026 1027 (fontified t syntax-table (15) face font-lock-string-face) 1027 1036 (fontified t) 1036 1037 (fontified t syntax-table (15) face font-lock-string-face) 1037 1040 (fontified t face font-lock-string-face) 1040 1047 (fontified t face font-lock-string-face) 1047 1048 (fontified t syntax-table (15) face font-lock-string-face) 1048 1050 (fontified t) 1050 1052 (fontified t) 1052 1070 (fontified t) 1070 1074 (fontified t face font-lock-builtin-face) 1074 1075 (fontified t) 1075 1076 (fontified t syntax-table (15) face font-lock-string-face) 1076 1083 (fontified t face font-lock-string-face) 1083 1084 (fontified t face font-lock-string-face) 1084 1085 (fontified t syntax-table (15) face font-lock-string-face) 1085 1087 (fontified t) 1087 1088 (fontified t) 1088 1092 (fontified t face font-lock-variable-name-face) 1092 1116 (fontified t) 1116 1117 (fontified t) 1117 1122 (fontified t face font-lock-keyword-face) 1122 1123 (fontified t) 1123 1128 (fontified t face font-lock-type-face) 1128 1129 (fontified t) 1129 1135 (fontified t face font-lock-builtin-face) 1135 1142 (fontified t) 1142 1145 (fontified t face font-lock-keyword-face) 1145 1146 (fontified t) 1146 1154 (fontified t face font-lock-function-name-face) 1154 1155 (fontified t) 1155 1159 (fontified t face font-lock-keyword-face) 1159 1206 (fontified t) 1206 1210 (fontified t face font-lock-keyword-face) 1210 1231 (fontified t) 1231 1234 (fontified t face font-lock-keyword-face) 1234 1248 (fontified t) 1248 1252 (fontified t face font-lock-keyword-face) 1252 1253 (fontified t) 1253 1257 (fontified t face font-lock-builtin-face) 1257 1270 (fontified t) 1270 1271 (fontified t syntax-table (15) face font-lock-string-face) 1271 1273 (fontified t face font-lock-string-face) 1273 1274 (fontified t syntax-table (15) face font-lock-string-face) 1274 1276 (fontified t) 1276 1278 (fontified t face font-lock-keyword-face) 1278 1282 (fontified t) 1282 1298 (fontified t) 1298 1300 (fontified t face font-lock-keyword-face) 1300 1327 (fontified t) 1327 1331 (fontified t face font-lock-keyword-face) 1331 1370 (fontified t) 1370 1374 (fontified t face font-lock-keyword-face) 1374 1396 (fontified t) 1396 1400 (fontified t face font-lock-keyword-face) 1400 1449 (fontified t) 1449 1450 (fontified t syntax-table (15) face font-lock-string-face) 1450 1453 (fontified t face font-lock-string-face) 1453 1454 (fontified t syntax-table (15) face font-lock-string-face) 1454 1490 (fontified t) 1490 1491 (fontified t syntax-table (15) face font-lock-string-face) 1491 1499 (fontified t face font-lock-string-face) 1499 1517 (face font-lock-string-face fontified t) 1517 1518 (syntax-table (15) face font-lock-string-face fontified t) 1518 1520 (fontified t) 1520 1528 (fontified t) 1528 1534 (fontified t face font-lock-keyword-face) 1534 1535 (fontified t) 1535 1550 (fontified t face font-lock-type-face) 1550 1552 (fontified t face font-lock-type-face) 1552 1554 (fontified t) 1554 1580 (fontified t) 1580 1581 (syntax-table (15) fontified t face font-lock-string-face) 1581 1587 (fontified t face font-lock-string-face) 1587 1590 (fontified t face font-lock-string-face) 1590 1605 (fontified t face font-lock-string-face) 1605 1606 (syntax-table (15) fontified t face font-lock-string-face) 1606 1608 (fontified t) 1608 1609 (fontified t) 1609 1616 (fontified t) 1616 1617 (fontified t) 1617 1621 (fontified t face font-lock-keyword-face) 1621 1656 (fontified t) 1656 1657 (fontified t) 1657 1673 (fontified t) 1673 1678 (fontified t) 1678 1679 (fontified t syntax-table (15) face font-lock-string-face) 1679 1715 (fontified t face font-lock-string-face) 1715 1716 (fontified t syntax-table (15) face font-lock-string-face) 1716 1717 (fontified t) 1717 1718 (fontified t) 1718 1719 (fontified t) 1719 1727 (fontified t) 1727 1731 (fontified t face font-lock-keyword-face) 1731 1758 (fontified t) 1758 1759 (fontified t) 1759 1775 (fontified t) 1775 1780 (fontified t) 1780 1781 (fontified t syntax-table (15) face font-lock-string-face) 1781 1824 (fontified t face font-lock-string-face) 1824 1825 (fontified t syntax-table (15) face font-lock-string-face) 1825 1826 (fontified t) 1826 1827 (fontified t) 1827 1835 (fontified t) 1835 1839 (fontified t face font-lock-keyword-face) 1839 1863 (fontified t) 1863 1864 (fontified t syntax-table (15) face font-lock-string-face) 1864 1872 (fontified t face font-lock-string-face) 1872 1873 (fontified t syntax-table (15) face font-lock-string-face) 1873 1876 (fontified t) 1876 1877 (fontified t syntax-table (15) face font-lock-string-face) 1877 1882 (fontified t face font-lock-string-face) 1882 1883 (fontified t syntax-table (15) face font-lock-string-face) 1883 1891 (fontified t) 1891 1895 (fontified t face font-lock-constant-face) 1895 1897 (fontified t) 1897 1905 (fontified t) 1905 1909 (fontified t face font-lock-constant-face) 1909 1910 (fontified t) 1910 1911 (fontified t) 1911 1927 (fontified t) 1927 1932 (fontified t) 1932 1933 (fontified t syntax-table (15) face font-lock-string-face) 1933 1990 (fontified t face font-lock-string-face) 1990 1998 (fontified t face font-lock-string-face) 1998 1999 (fontified t syntax-table (15) face font-lock-string-face) 1999 2000 (fontified t) 2000 2001 (fontified t) 2001 2009 (fontified t) 2009 2013 (fontified t face font-lock-keyword-face) 2013 2037 (fontified t) 2037 2038 (fontified t syntax-table (15) face font-lock-string-face) 2038 2046 (fontified t face font-lock-string-face) 2046 2047 (fontified t syntax-table (15) face font-lock-string-face) 2047 2050 (fontified t) 2050 2051 (fontified t syntax-table (15) face font-lock-string-face) 2051 2062 (fontified t face font-lock-string-face) 2062 2063 (fontified t syntax-table (15) face font-lock-string-face) 2063 2071 (fontified t) 2071 2075 (fontified t face font-lock-constant-face) 2075 2085 (fontified t) 2085 2089 (fontified t face font-lock-constant-face) 2089 2090 (fontified t) 2090 2091 (fontified t) 2091 2112 (fontified t) 2112 2113 (fontified t syntax-table (15) face font-lock-string-face) 2113 2140 (fontified t face font-lock-string-face) 2140 2141 (fontified t face font-lock-string-face) 2141 2153 (fontified t face font-lock-string-face) 2153 2154 (fontified t face font-lock-string-face) 2154 2163 (fontified t face font-lock-string-face) 2163 2164 (fontified t syntax-table (15) face font-lock-string-face) 2164 2165 (fontified t) 2165 2166 (fontified t) 2166 2174 (fontified t) 2174 2178 (fontified t face font-lock-keyword-face) 2178 2185 (fontified t) 2185 2186 (fontified t syntax-table (15) face font-lock-string-face) 2186 2192 (fontified t face font-lock-string-face) 2192 2193 (fontified t syntax-table (15) face font-lock-string-face) 2193 2197 (fontified t) 2197 2201 (fontified t face font-lock-keyword-face) 2201 2225 (fontified t) 2225 2226 (fontified t syntax-table (15) face font-lock-string-face) 2226 2231 (fontified t face font-lock-string-face) 2231 2232 (fontified t syntax-table (15) face font-lock-string-face) 2232 2234 (fontified t) 2234 2235 (fontified t syntax-table (15) face font-lock-string-face) 2235 2236 (fontified t syntax-table (15) face font-lock-string-face) 2236 2244 (fontified t) 2244 2248 (fontified t face font-lock-constant-face) 2248 2249 (fontified t) 2249 2250 (fontified t) 2250 2266 (fontified t) 2266 2271 (fontified t) 2271 2272 (fontified t syntax-table (15) face font-lock-string-face) 2272 2336 (fontified t face font-lock-string-face) 2336 2337 (fontified t syntax-table (15) face font-lock-string-face) 2337 2338 (fontified t) 2338 2339 (fontified t) 2339 2347 (fontified t) 2347 2351 (fontified t face font-lock-keyword-face) 2351 2358 (fontified t) 2358 2359 (syntax-table (15) fontified t face font-lock-string-face) 2359 2375 (fontified t face font-lock-string-face) 2375 2376 (syntax-table (15) fontified t face font-lock-string-face) 2376 2380 (fontified t) 2380 2384 (fontified t face font-lock-keyword-face) 2384 2391 (fontified t) 2391 2396 (fontified t face font-lock-builtin-face) 2396 2398 (fontified t) 2398 2403 (fontified t) 2403 2410 (fontified t) 2410 2416 (fontified t face font-lock-keyword-face) 2416 2437 (fontified t) 2437 2438 (fontified t) 2438 2439 (fontified t syntax-table (15) face font-lock-string-face) 2439 2442 (fontified t face font-lock-string-face) 2442 2443 (fontified t syntax-table (15) face font-lock-string-face) 2443 2447 (fontified t) 2447 2448 (fontified t syntax-table (15) face font-lock-string-face) 2448 2453 (fontified t face font-lock-string-face) 2453 2454 (fontified t syntax-table (15) face font-lock-string-face) 2454 2465 (fontified t) 2465 2466 (fontified t) 2466 2482 (fontified t) 2482 2487 (fontified t) 2487 2488 (fontified t syntax-table (15) face font-lock-string-face) 2488 2558 (fontified t face font-lock-string-face) 2558 2559 (fontified t syntax-table (15) face font-lock-string-face) 2559 2560 (fontified t) 2560 2561 (fontified t) 2561 2569 (fontified t) 2569 2573 (fontified t face font-lock-keyword-face) 2573 2580 (fontified t) 2580 2581 (syntax-table (15) fontified t face font-lock-string-face) 2581 2582 (fontified t face font-lock-string-face) 2582 2586 (fontified t face font-lock-string-face) 2586 2600 (fontified t face font-lock-string-face) 2600 2601 (syntax-table (15) fontified t face font-lock-string-face) 2601 2605 (fontified t) 2605 2609 (fontified t face font-lock-keyword-face) 2609 2616 (fontified t) 2616 2621 (fontified t face font-lock-builtin-face) 2621 2623 (fontified t) 2623 2635 (fontified t) 2635 2641 (fontified t face font-lock-keyword-face) 2641 2663 (fontified t) 2663 2664 (fontified t syntax-table (15) face font-lock-string-face) 2664 2667 (fontified t face font-lock-string-face) 2667 2668 (fontified t syntax-table (15) face font-lock-string-face) 2668 2672 (fontified t) 2672 2673 (fontified t syntax-table (15) face font-lock-string-face) 2673 2676 (fontified t face font-lock-string-face) 2676 2680 (fontified t face font-lock-string-face) 2680 2681 (fontified t syntax-table (15) face font-lock-string-face) 2681 2692 (fontified t) 2692 2693 (fontified t) 2693 2701 (fontified t) 2701 2709 (fontified t) 2709 2714 (fontified t) 2714 2715 (fontified t syntax-table (15) face font-lock-string-face) 2715 2750 (fontified t face font-lock-string-face) 2750 2751 (fontified t face font-lock-string-face) 2751 2788 (fontified t face font-lock-string-face) 2788 2789 (fontified t syntax-table (15) face font-lock-string-face) 2789 2790 (fontified t rear-nonsticky t) 2790 2791 (fontified t) 2791 2792 (fontified t) 2792 2793 (fontified t) 2793 2797 (fontified t) 2797 2800 (fontified t face font-lock-keyword-face) 2800 2801 (fontified t) 2801 2812 (fontified t face font-lock-function-name-face) 2812 2813 (fontified t) 2813 2817 (fontified t face font-lock-keyword-face) 2817 2820 (fontified t) 2820 2828 (fontified t) 2828 2831 (fontified t face font-lock-keyword-face) 2831 2834 (fontified t) 2834 2836 (fontified t face font-lock-keyword-face) 2836 2837 (fontified t) 2837 2842 (fontified t face font-lock-builtin-face) 2842 2843 (fontified t) 2843 2846 (fontified t) 2846 2849 (fontified t face font-lock-builtin-face) 2849 2850 (fontified t) 2850 2854 (fontified t face font-lock-keyword-face) 2854 2860 (fontified t) 2860 2861 (fontified t) 2861 2862 (fontified t) 2862 2864 (fontified t) 2864 2876 (fontified t) 2876 2882 (fontified t face font-lock-variable-name-face) 2882 2888 (fontified t ws-butler-chg chg face font-lock-variable-name-face) 2888 2891 (fontified t) 2891 2895 (fontified t face font-lock-keyword-face) 2895 2911 (fontified t) 2911 2919 (fontified t ws-butler-chg chg) 2919 2920 (fontified t) 2920 2932 (fontified t) 2932 2945 (fontified t face font-lock-variable-name-face) 2945 2951 (fontified t ws-butler-chg chg face font-lock-variable-name-face) 2951 2954 (fontified t) 2954 2958 (fontified t face font-lock-keyword-face) 2958 2985 (fontified t) 2985 2997 (fontified t) 2997 3012 (fontified t face font-lock-variable-name-face) 3012 3015 (fontified t) 3015 3019 (fontified t face font-lock-keyword-face) 3019 3039 (fontified t) 3039 3040 (ws-butler-chg chg fontified t) 3040 3048 (fontified t) 3048 3049 (ws-butler-chg chg fontified t) 3049 3050 (ws-butler-chg delete fontified t) 3050 3062 (ws-butler-chg chg fontified t) 3062 3063 (fontified t) 3063 3064 (fontified t) 3064 3065 (fontified t face font-lock-comment-delimiter-face) 3065 3080 (fontified t face font-lock-comment-face) 3080 3081 (fontified t face font-lock-comment-face syntax-table (15)) 3081 3089 (fontified t face font-lock-comment-face) 3089 3090 (fontified t face font-lock-comment-face syntax-table (15)) 3090 3092 (fontified t face font-lock-comment-face)) 2951) #f(compiled-function (result) #<bytecode 0x4ab4b011>) nil)
  elpy-rpc-get-completions(#f(compiled-function (result) #<bytecode 0x4ab4b011>))
  #f(compiled-function (callback) #<bytecode 0x4ab554bd>)(#f(compiled-function (candidates) #<bytecode 0x4ab3db69>))
  company--fetch-candidates(#("intended_sent_words" 0 13 (fontified t face font-lock-variable-name-face) 13 19 (fontified t ws-butler-chg chg face font-lock-variable-name-face)))
  company-calculate-candidates(#("intended_sent_words" 0 13 (fontified t face font-lock-variable-name-face) 13 19 (fontified t ws-butler-chg chg face font-lock-variable-name-face)) nil)
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-idle-begin(#<buffer get_moses_metrics.py> #<window 3 on get_moses_metrics.py> 37450 2952)
  apply(company-idle-begin (#<buffer get_moses_metrics.py> #<window 3 on get_moses_metrics.py> 37450 2952))
  timer-event-handler([t 24035 55804 456389 nil company-idle-begin (#<buffer get_moses_metrics.py> #<window 3 on get_moses_metrics.py> 37450 2952) nil 0])

Even if I hit C-g immediatley upon Emacs locking up, it still takes a good 45 seconds to actually quit and produce the trace, which is really frustrating. This is also happening multiple times in the span of a few minutes, so I effectively cannot use elpy (or Emacs) at all.

I'm not sure if this is conicidental or not, but it seems like this is happening to me the most when writing code involving pandas.

Here's my elpy-config:

Elpy Configuration

Emacs.............: 26.3
Elpy..............: 1.32.0
Virtualenv........: greenRNNs (/Users/adamliter/.pyenv/versions/greenRNNs)
Interactive Python: python 3.5.8 (/Users/adamliter/.pyenv/versions/greenRNNs/bin/python)
RPC virtualenv....: greenRNNs (/Users/adamliter/.pyenv/versions/greenRNNs)
 Python...........: python 3.5.8 (/Users/adamliter/.pyenv/versions/greenRNNs/bin/python)
 Jedi.............: 0.15.1
 Rope.............: 0.14.0
 Autopep8.........: 1.4.4
 Yapf.............: 0.28.0
 Black............: Not found
Syntax checker....: flake8 (/Users/adamliter/.pyenv/shims/flake8)

Warnings

The black package is not available. Commands using this will not work.

[Install black]

Options

`Raised' text indicates buttons; type RET or click mouse-1 on a button
to invoke its action.  Invoke [+] to expand a group, and [-] to collapse
an expanded group.  Invoke the [Group], [Face], and [Option] buttons
below to edit that item in another window.

I'm running macOS Mojave (version 10.14.6 (18G95)).


Edit 1:

Perhaps this is a company mode problem, not an elpy problem. I just disabled elpy, but I'm still seeing this issue intermittently. With elpy disabled, the backtrace that I see with toggle-debug-on-quit is now:

Debugger entered--Lisp error: (quit)
  company--fetch-candidates(#("elif" 0 4 (fontified t ws-butler-chg chg face font-lock-keyword-face)))
  company-calculate-candidates(#("elif" 0 4 (fontified t ws-butler-chg chg face font-lock-keyword-face)) nil)
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-idle-begin(#<buffer get_moses_metrics.py> #<window 12 on get_moses_metrics.py> 44769 3025)
  apply(company-idle-begin (#<buffer get_moses_metrics.py> #<window 12 on get_moses_metrics.py> 44769 3025))
  timer-event-handler([t 24035 57634 100287 nil company-idle-begin (#<buffer get_moses_metrics.py> #<window 12 on get_moses_metrics.py> 44769 3025) nil 0])

Edit 2:

That being said, I'm also seeing this behavior with just elpy in the traceback, so maybe it is an issue with both ... ?

Debugger entered--Lisp error: (quit)
  process-send-string(#<process  *elpy-rpc [project:~/projects/ling723_course_project/gulordava_etal2018/src/ environment:/Users/adamliter/.pyenv/versions/greenRNNs]*> "{\"id\":3752,\"method\":\"get_oneline_docstring\",\"params\":[\"/Users/adamliter/projects/ling723_course_project/gulordava_etal2018/src/get_moses_metrics.py\",{\"filename\":\"/var/folders/42/_h6s0gkj6mzgvq6k8hf_ncrr0000gn/T/elpy-rpc-NzPRJp\",\"delete_after_use\":true},6746]}\n")
  elpy-rpc--call("get_oneline_docstring" ("/Users/adamliter/projects/ling723_course_project/gulordava_etal2018/src/get_moses_metrics.py" ((filename . "/var/folders/42/_h6s0gkj6mzgvq6k8hf_ncrr0000gn/T/elpy-rpc-NzPRJp") (delete_after_use . t)) 6746) #f(compiled-function (doc) #<bytecode 0x4a92eab9>) elpy-rpc--default-error-callback)
  elpy-rpc("get_oneline_docstring" ("/Users/adamliter/projects/ling723_course_project/gulordava_etal2018/src/get_moses_metrics.py" ((filename . "/var/folders/42/_h6s0gkj6mzgvq6k8hf_ncrr0000gn/T/elpy-rpc-NzPRJp") (delete_after_use . t)) 6746) #f(compiled-function (doc) #<bytecode 0x4a92eab9>) nil)
  elpy-rpc-get-oneline-docstring(#f(compiled-function (doc) #<bytecode 0x4a92eab9>))
  #f(compiled-function (calltip) #<bytecode 0x4a92eaf1>)(nil)
  elpy-promise-resolve([*elpy-promise* #f(compiled-function (calltip) #<bytecode 0x4a92eaf1>) elpy-rpc--default-error-callback #<buffer get_moses_metrics.py> nil] nil)
  elpy-rpc--handle-json(((result) (id . 3482)))
  elpy-rpc--filter(#<process  *elpy-rpc [project:~/projects/ling723_course_project/gulordava_etal2018/src/ environment:/Users/adamliter/.pyenv/versions/greenRNNs]*> "{\"result\": null, \"id\": 3482}\n")
  process-send-string(#<process  *elpy-rpc [project:~/projects/ling723_course_project/gulordava_etal2018/src/ environment:/Users/adamliter/.pyenv/versions/greenRNNs]*> "{\"id\":3751,\"method\":\"get_calltip\",\"params\":[\"/Users/adamliter/projects/ling723_course_project/gulordava_etal2018/src/get_moses_metrics.py\",{\"filename\":\"/var/folders/42/_h6s0gkj6mzgvq6k8hf_ncrr0000gn/T/elpy-rpc-i3C3Mk\",\"delete_after_use\":true},6746]}\n")
  elpy-rpc--call("get_calltip" ("/Users/adamliter/projects/ling723_course_project/gulordava_etal2018/src/get_moses_metrics.py" ((filename . "/var/folders/42/_h6s0gkj6mzgvq6k8hf_ncrr0000gn/T/elpy-rpc-i3C3Mk") (delete_after_use . t)) 6746) #f(compiled-function (calltip) #<bytecode 0x4a92eaf1>) elpy-rpc--default-error-callback)
  elpy-rpc("get_calltip" ("/Users/adamliter/projects/ling723_course_project/gulordava_etal2018/src/get_moses_metrics.py" ((filename . "/var/folders/42/_h6s0gkj6mzgvq6k8hf_ncrr0000gn/T/elpy-rpc-i3C3Mk") (delete_after_use . t)) 6746) #f(compiled-function (calltip) #<bytecode 0x4a92eaf1>) nil)
  elpy-rpc-get-calltip(#f(compiled-function (calltip) #<bytecode 0x4a92eaf1>))
  elpy-eldoc-documentation()
  eldoc-print-current-symbol-info()
  #f(compiled-function () #<bytecode 0x400f18cf>)()
  apply(#f(compiled-function () #<bytecode 0x400f18cf>) nil)
  timer-event-handler([t 0 0 500000 nil #f(compiled-function () #<bytecode 0x400f18cf>) nil idle 0])
galaunay commented 4 years ago

The two tracebacks with Elpy enabled show that Emacs is hanging waiting for the RPC to return completion candidates or docstrings. It is quite weird because the functions in question are called asynchroneously. So even if the RPC is not returning anything, it is not supposed to block Emacs.

Do you have elpy-rpc-timeout set to something ?

The reason why company is hanging as well is quite obscure to me.

Nicholas-Autio-Mitchell commented 4 years ago

Back when I had that problem all the time I also had the feeling it was triggered when docstrings were being loaded. Especially on packages like Numpy and Tensorflow that have a huge number of modules and nested modules. I guess the loading isn't truly async, or perhaps some package is waiting on that prices to finish e.g. to display the docstrings is unable to proceed in some way or doesn't exit.

I ended up having to kill elpy in terminal every time because it didn't always recover.

On Tue, 10 Dec 2019, 23:02 galaunay, notifications@github.com wrote:

The two tracebacks with Elpy enabled show that Emacs is hanging waiting for the RPC to return completion candidates or docstrings. It is quite weird because the functions in question are called asynchroneously. So even if the RPC is not returning anything, it is not supposed to block Emacs.

Do you have elpy-rpc-timeout set to something ?

The reason why company is hanging as well is quite obscure to me.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jorgenschaefer/elpy/issues/709?email_source=notifications&email_token=ADB2DJJ6DEMSQSRZLD2JQBTQYAGX3A5CNFSM4BTY53QKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGRDQ3Q#issuecomment-564279406, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADB2DJIXUSYWUPZGJPEEJGTQYAGX3ANCNFSM4BTY53QA .

Aaronzinhoo commented 3 years ago

I actually just just hit the same problem as @adamliter on wsl2 with emacs. I restarted the elpy-rpc processes and it began to work again. This problem was only experienced after I start to use pytest package for my unit testing. I do not know if it the docstring or not but I have only had this issue when pytest. Company hanging could be due to using company-quickhelp but I cannot tell for sure.

galaunay commented 3 years ago

If the problem is related to pytest, it could be useful to know how Jedi does its thing. Running the following script will ask Jedi to analyse the pytest library:

import jedi

code = """import pytest
pytest."""
script = jedi.Script(code)
defi = script.complete(2, 7)
print(defi)

If it is working properly and not taking ages to run, the problem is probably in Elpy itself...

dougharris commented 1 year ago

I see emacs hang when I start the doc string of a new class method. I've been able to reproduce this with a custom emacs init file. I'm using Emacs 28.2 from https://emacsformacosx.com/.

To duplicate what I'm seeing:

  1. Download the custom init file, hang.el: https://gist.github.com/dougharris/397d2a58d6698e6006905135d44e0177
  2. Download the sample file, notadmin.py (based on a django admin.py): https://gist.github.com/dougharris/5b867befa003a5f7de87ffc5b15333c7
  3. Start emacs without its default init file (-q) and load this custom init file (--load hang.el). On my mac, I did /Applications/Emacs.app/Contents/MacOS/Emacs -q --load hang.el
  4. Open notadmin.py
  5. At line 98, in class UserInline start adding a new method:
    def new_method(self):
        """

After I hit those three quotes, emacs stops responding. Its CPU usage climbs and I have to kill it.

captainnova commented 1 year ago

I see emacs hang when I start the doc string of a new class method. ... After I hit those three quotes, emacs stops responding. Its CPU usage climbs and I have to kill it.

I also tend to get the problem when I open a string and don't close it right away, although in today's case it was a single '. I can interrupt it with kill -12 and get a Backtrace buffer, but I can't remove or close the string before it hangs again.

Here's the *Backtrace* buffer:

Debugger entered--entering a function:
* #f(compiled-function () #<bytecode 0x8833d76537d140a>)()
  syntax-ppss()
  python-nav-end-of-statement()
  python-nav-end-of-defun()
  python-info-current-defun()
  (let ((current-defun (python-info-current-defun))) (if current-defun (progn (eldoc-message (concat "In: " (propertize (format "%s()" current-defun) 'face 'font-lock-function-name-face))))))
  (progn (let ((current-defun (python-info-current-defun))) (if current-defun (progn (eldoc-message (concat "In: " (propertize (format "%s()" current-defun) 'face 'font-lock-function-name-face)))))))
  (if elpy-eldoc-show-current-function (progn (let ((current-defun (python-info-current-defun))) (if current-defun (progn (eldoc-message (concat "In: " (propertize ... ... ...))))))))
  (cond ((stringp info) (funcall cb info)) ((string= (cdr (assq 'kind info)) "calltip") (let ((name (cdr (assq 'name info))) (index (cdr (assq 'index info))) (params (cdr (assq 'params info)))) (if index (progn (let* ((c ...)) (setcar c (propertize ... ... ...))))) (let* ((prefix (propertize name 'face 'font-lock-function-name-face)) (args (format "%s(%s)" prefix (mapconcat ... params ", ")))) (funcall cb args)))) ((string= (cdr (assq 'kind info)) "oneline_doc") (let ((name (cdr (assq 'name info))) (docs (cdr (assq 'doc info)))) (funcall cb docs :thing name :face 'font-lock-function-name-face))) (t (if elpy-eldoc-show-current-function (progn (let ((current-defun (python-info-current-defun))) (if current-defun (progn (eldoc-message ...))))))))
  (closure ((flymake-error) (cb . #f(compiled-function (string &rest plist) #<bytecode 0x2cb3448e18d688a>)) (_more) (callback . #f(compiled-function (string &rest plist) #<bytecode 0x2cb3448e18d688a>)) cl-struct-xref-elpy-location-tags t) (info) (cond ((stringp info) (funcall cb info)) ((string= (cdr (assq 'kind info)) "calltip") (let ((name (cdr ...)) (index (cdr ...)) (params (cdr ...))) (if index (progn (let* ... ...))) (let* ((prefix ...) (args ...)) (funcall cb args)))) ((string= (cdr (assq 'kind info)) "oneline_doc") (let ((name (cdr ...)) (docs (cdr ...))) (funcall cb docs :thing name :face 'font-lock-function-name-face))) (t (if elpy-eldoc-show-current-function (progn (let (...) (if current-defun ...)))))))(nil)
  funcall((closure ((flymake-error) (cb . #f(compiled-function (string &rest plist) #<bytecode 0x2cb3448e18d688a>)) (_more) (callback . #f(compiled-function (string &rest plist) #<bytecode 0x2cb3448e18d688a>)) cl-struct-xref-elpy-location-tags t) (info) (cond ((stringp info) (funcall cb info)) ((string= (cdr (assq 'kind info)) "calltip") (let ((name (cdr ...)) (index (cdr ...)) (params (cdr ...))) (if index (progn (let* ... ...))) (let* ((prefix ...) (args ...)) (funcall cb args)))) ((string= (cdr (assq 'kind info)) "oneline_doc") (let ((name (cdr ...)) (docs (cdr ...))) (funcall cb docs :thing name :face 'font-lock-function-name-face))) (t (if elpy-eldoc-show-current-function (progn (let (...) (if current-defun ...))))))) nil)
  (save-current-buffer (set-buffer (elpy-promise-buffer promise)) (funcall success-callback value))
  (condition-case err (save-current-buffer (set-buffer (elpy-promise-buffer promise)) (funcall success-callback value)) (error (elpy-promise-reject promise err)))
  (progn (condition-case err (save-current-buffer (set-buffer (elpy-promise-buffer promise)) (funcall success-callback value)) (error (elpy-promise-reject promise err))))
  (if success-callback (progn (condition-case err (save-current-buffer (set-buffer (elpy-promise-buffer promise)) (funcall success-callback value)) (error (elpy-promise-reject promise err)))))
  (let ((success-callback (elpy-promise-success-callback promise))) (if success-callback (progn (condition-case err (save-current-buffer (set-buffer (elpy-promise-buffer promise)) (funcall success-callback value)) (error (elpy-promise-reject promise err))))))
  (unwind-protect (let ((success-callback (elpy-promise-success-callback promise))) (if success-callback (progn (condition-case err (save-current-buffer (set-buffer (elpy-promise-buffer promise)) (funcall success-callback value)) (error (elpy-promise-reject promise err)))))) (elpy-promise-set-resolved promise))
  (if (elpy-promise-resolved-p promise) nil (unwind-protect (let ((success-callback (elpy-promise-success-callback promise))) (if success-callback (progn (condition-case err (save-current-buffer (set-buffer ...) (funcall success-callback value)) (error (elpy-promise-reject promise err)))))) (elpy-promise-set-resolved promise)))
  elpy-promise-resolve([*elpy-promise* (closure ((flymake-error) (cb . #f(compiled-function (string &rest plist) #<bytecode 0x2cb3448e18d688a>)) (_more) (callback . #f(compiled-function (string &rest plist) #<bytecode 0x2cb3448e18d688a>)) cl-struct-xref-elpy-location-tags t) (info) (cond ((stringp info) (funcall cb info)) ((string= (cdr (assq ... info)) "calltip") (let ((name ...) (index ...) (params ...)) (if index (progn ...)) (let* (... ...) (funcall cb args)))) ((string= (cdr (assq ... info)) "oneline_doc") (let ((name ...) (docs ...)) (funcall cb docs :thing name :face 'font-lock-function-name-face))) (t (if elpy-eldoc-show-current-function (progn (let ... ...)))))) elpy-rpc--default-error-callback #<buffer subjdate_csv_to_scaninfo.py> nil] nil)
  (if error-object (elpy-promise-reject promise error-object) (elpy-promise-resolve promise result))
  (let ((promise (gethash call-id elpy-rpc--backend-callbacks))) (if promise nil (error "Received a response for unknown call-id %s" call-id)) (remhash call-id elpy-rpc--backend-callbacks) (if error-object (elpy-promise-reject promise error-object) (elpy-promise-resolve promise result)))
  (let ((call-id (cdr (assq 'id json))) (error-object (cdr (assq 'error json))) (result (cdr (assq 'result json)))) (let ((promise (gethash call-id elpy-rpc--backend-callbacks))) (if promise nil (error "Received a response for unknown call-id %s" call-id)) (remhash call-id elpy-rpc--backend-callbacks) (if error-object (elpy-promise-reject promise error-object) (elpy-promise-resolve promise result))))
  elpy-rpc--handle-json(((result) (id . 7)))
  (cond (did-read-json (delete-region (point-min) line-end) (elpy-rpc--handle-json json)) ((looking-at "elpy-rpc ready\n") (replace-match "") (elpy-rpc--check-backend-version "1.1")) ((looking-at "elpy-rpc ready (\\([^ ]*\\))\n") (let ((rpc-version (match-string 1))) (replace-match "") (elpy-rpc--check-backend-version rpc-version))) ((looking-at ".*No module named elpy\n") (replace-match "") (elpy-config-error "Elpy module not found")) (t (let ((line (buffer-substring (point-min) line-end))) (delete-region (point-min) line-end) (elpy-rpc--handle-unexpected-line line))))
  (let ((line-end (point)) (json nil) (did-read-json nil)) (goto-char (point-min)) (condition-case _err (progn (setq json (let ((json-array-type 'list) (json-false nil) (json-encoding-pretty-print nil)) (json-read))) (if (listp json) (setq line-end (1+ (point)) did-read-json t) (goto-char (point-min)))) (error (goto-char (point-min)))) (cond (did-read-json (delete-region (point-min) line-end) (elpy-rpc--handle-json json)) ((looking-at "elpy-rpc ready\n") (replace-match "") (elpy-rpc--check-backend-version "1.1")) ((looking-at "elpy-rpc ready (\\([^ ]*\\))\n") (let ((rpc-version (match-string 1))) (replace-match "") (elpy-rpc--check-backend-version rpc-version))) ((looking-at ".*No module named elpy\n") (replace-match "") (elpy-config-error "Elpy module not found")) (t (let ((line (buffer-substring (point-min) line-end))) (delete-region (point-min) line-end) (elpy-rpc--handle-unexpected-line line)))))
  (while (progn (goto-char (point-min)) (search-forward "\n" nil t)) (let ((line-end (point)) (json nil) (did-read-json nil)) (goto-char (point-min)) (condition-case _err (progn (setq json (let ((json-array-type ...) (json-false nil) (json-encoding-pretty-print nil)) (json-read))) (if (listp json) (setq line-end (1+ (point)) did-read-json t) (goto-char (point-min)))) (error (goto-char (point-min)))) (cond (did-read-json (delete-region (point-min) line-end) (elpy-rpc--handle-json json)) ((looking-at "elpy-rpc ready\n") (replace-match "") (elpy-rpc--check-backend-version "1.1")) ((looking-at "elpy-rpc ready (\\([^ ]*\\))\n") (let ((rpc-version (match-string 1))) (replace-match "") (elpy-rpc--check-backend-version rpc-version))) ((looking-at ".*No module named elpy\n") (replace-match "") (elpy-config-error "Elpy module not found")) (t (let ((line (buffer-substring ... line-end))) (delete-region (point-min) line-end) (elpy-rpc--handle-unexpected-line line))))))
  (save-current-buffer (set-buffer buffer) (goto-char (point-max)) (insert output) (while (progn (goto-char (point-min)) (search-forward "\n" nil t)) (let ((line-end (point)) (json nil) (did-read-json nil)) (goto-char (point-min)) (condition-case _err (progn (setq json (let (... ... ...) (json-read))) (if (listp json) (setq line-end (1+ ...) did-read-json t) (goto-char (point-min)))) (error (goto-char (point-min)))) (cond (did-read-json (delete-region (point-min) line-end) (elpy-rpc--handle-json json)) ((looking-at "elpy-rpc ready\n") (replace-match "") (elpy-rpc--check-backend-version "1.1")) ((looking-at "elpy-rpc ready (\\([^ ]*\\))\n") (let ((rpc-version ...)) (replace-match "") (elpy-rpc--check-backend-version rpc-version))) ((looking-at ".*No module named elpy\n") (replace-match "") (elpy-config-error "Elpy module not found")) (t (let ((line ...)) (delete-region (point-min) line-end) (elpy-rpc--handle-unexpected-line line)))))))
  (progn (save-current-buffer (set-buffer buffer) (goto-char (point-max)) (insert output) (while (progn (goto-char (point-min)) (search-forward "\n" nil t)) (let ((line-end (point)) (json nil) (did-read-json nil)) (goto-char (point-min)) (condition-case _err (progn (setq json (let ... ...)) (if (listp json) (setq line-end ... did-read-json t) (goto-char ...))) (error (goto-char (point-min)))) (cond (did-read-json (delete-region (point-min) line-end) (elpy-rpc--handle-json json)) ((looking-at "elpy-rpc ready\n") (replace-match "") (elpy-rpc--check-backend-version "1.1")) ((looking-at "elpy-rpc ready (\\([^ ]*\\))\n") (let (...) (replace-match "") (elpy-rpc--check-backend-version rpc-version))) ((looking-at ".*No module named elpy\n") (replace-match "") (elpy-config-error "Elpy module not found")) (t (let (...) (delete-region ... line-end) (elpy-rpc--handle-unexpected-line line))))))))
  (if (and buffer (buffer-live-p buffer)) (progn (save-current-buffer (set-buffer buffer) (goto-char (point-max)) (insert output) (while (progn (goto-char (point-min)) (search-forward "\n" nil t)) (let ((line-end (point)) (json nil) (did-read-json nil)) (goto-char (point-min)) (condition-case _err (progn (setq json ...) (if ... ... ...)) (error (goto-char ...))) (cond (did-read-json (delete-region ... line-end) (elpy-rpc--handle-json json)) ((looking-at "elpy-rpc ready\n") (replace-match "") (elpy-rpc--check-backend-version "1.1")) ((looking-at "elpy-rpc ready (\\([^ ]*\\))\n") (let ... ... ...)) ((looking-at ".*No module named elpy\n") (replace-match "") (elpy-config-error "Elpy module not found")) (t (let ... ... ...))))))))
  (let ((buffer (process-buffer process))) (if (and buffer (buffer-live-p buffer)) (progn (save-current-buffer (set-buffer buffer) (goto-char (point-max)) (insert output) (while (progn (goto-char (point-min)) (search-forward "\n" nil t)) (let ((line-end ...) (json nil) (did-read-json nil)) (goto-char (point-min)) (condition-case _err (progn ... ...) (error ...)) (cond (did-read-json ... ...) (... ... ...) (... ...) (... ... ...) (t ...))))))))
  elpy-rpc--filter(#<process  *elpy-rpc [project:/mnt/data/m101013/adir_spm12/ environment:/home/m101013/.cache/pypoetry/virtualenvs/rocky8-3.8-iuxOHl-8-py3.8]*> "{\"result\": null, \"id\": 7}\n")
  recursive-edit()
  debug(lambda)

(it repeated once)

  elpy-rpc--filter(#<process  *elpy-rpc [project:/mnt/data/m101013/adir_spm12/ environment:~/.cache/pypoetry/virtualenvs/rocky8-3.8-iuxOHl-8-py3.8]*> "{\"result\": null, \"id\": 6}\n")
dougharris commented 1 year ago

Glad you were able to recreate the behavior @captainnova. Any thoughts on what's going wrong here?

captainnova commented 1 year ago

I think it's trying to do some action, either on every keypress or some period around a second, which hangs if the buffer is currently invalid python. The action might be syntax highlighting, flake8, company completion, or yasnippet completion (but I don't think point is at a yasnippet code when it hangs, and I did not hit tab). It does not happen every time I open a str, or have invalid python; usually flake8 is happy to tell me what I did wrong. I suspect it goes into some sort of recursion when the dangling text matches some condition.

I actually was able to recover by rapidly alternating kill -12 and/or C-g a LOT, and quickly fixing the str. It wasn't easy because point had moved away from it.

nkrishnaswami commented 1 year ago

I've taken to opening and closing quotes (C-u 6 ', or '') before I start on their contents because the hang happens to me so often (but, infuriatingly, not always). Are there any diagnostics I can try running to help diagnose/fix it next time it occurs?

dougharris commented 1 year ago

I switched from elpy to eglot+pyright… so, no I didn’t determine a fix to this.

On Thu, Jun 29, 2023 at 12:53 PM Natarajan Krishnaswami < @.***> wrote:

I've taken to opening and closing quotes (C-u 6 ', or '') before I start on their contents because the hang happens to me so often (but, infuriatingly, not always). Are there any diagnostics I can try running to help diagnose/fix it next time it occurs?

— Reply to this email directly, view it on GitHub https://github.com/jorgenschaefer/elpy/issues/709#issuecomment-1613527765, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGFJ6KQVQXVAERD2IA2UWDXNWXIXANCNFSM4BTY53QA . You are receiving this because you commented.Message ID: @.***>

--

Doug Harris - @., @. Washington, DC