tech-srl / code2seq

Code for the model presented in the paper: "code2seq: Generating Sequences from Structured Representations of Code"
http://code2seq.org
MIT License
556 stars 164 forks source link

Unexpected TimeoutError #20

Closed Jianwei-Wu-1 closed 5 years ago

Jianwei-Wu-1 commented 5 years ago

Traceback (most recent call last): File "code2seq.py", line 40, in predictor.predict() File "/Users/wujianwei/Desktop/code2seq/interactive_predict.py", line 35, in predict predict_lines, pc_info_dict = self.path_extractor.extract_paths(user_input) File "/Users/wujianwei/Desktop/code2seq/extractor.py", line 26, in extract_paths raise TimeoutError(response.text) TimeoutError: {"errorMessage":"2019-10-22T15:45:25.088Z 6b98c48f-5456-4690-9e5f-2b6e84894521 Task timed out after 19.02 seconds"} -Error message.

Hi, researchers from tech-srl: I tried to use the default model to predict a long program, but instead of giving me predicted names, the tool gave me the error message above. I'm not sure how to fix it, and I already checked the code. I guess the JSON parser might not be able to parse large programs or I did something wrong?

Best, Jianwei Wu

urialon commented 5 years ago

Hi Jianwei, Thank you for your interest in code2seq.

  1. Just out of curiosity - how long are the programs that you have tried?
  2. In general yes, because we constructed this for demo purposes, we set a timeout of about 20 seconds. Path extraction happens remotely (on an AWS lambda), and the neural network prediction is computed on the user's machine.
  3. Longer programs can be preprocessed in advance (as if you are creating a new dataset) and fed to the model using the --test flag.
  4. If you really want to have the interactive behavior - you can modify the Java code and add a local server that accepts HTTP requests on "localhost" and return the result; and then redirect the python code to query the "localhost" instead of the AWS lambda...

I hope it helps. Best, Uri

Jianwei-Wu-1 commented 5 years ago

@urialon Thanks for the quick reply!

My program has roughly 189 lines of code. Sure, I will try to preprocess my long program and try again (I know the --test flag). I will let you know if I have any further issues.

Best, Jianwei Wu

Guardian99 commented 4 years ago

Can you tell the specific line where it is referring to AWS lambda since i am not able to find it in the structure

urialon commented 4 years ago

Hi @Guardian99 , Also this is an old thread - this is the line that calls the path-extraction Lambda: https://github.com/tech-srl/code2seq/blob/master/extractor.py#L18

Best, Uri

Guardian99 commented 4 years ago

How do i change it to a Localhost? Any help would be really appreciated.

urialon commented 4 years ago

I think that easiest solution will probably be running a Java subprocess, on your local host, that will extract paths (instead of sending the request to the remote lambda).

This subprocess can have a similar command to the command of the preprocessing step: https://github.com/tech-srl/code2seq/blob/master/JavaExtractor/extract.py#L26

Except that instead of a --dir flag - give it a --file flag, and the path of the input.java file.