Closed lyriccoder closed 2 years ago
Hi @lyriccoder , Thank you for your interest in our project, and thank you for reporting this!
I will check why the Amazon service is down.
Uri
Hey @lyriccoder , Can you check now, please?
I still have the same issue. Is it possible to implement that service inside the current framework (predict without an http requests)? Maybe I can help?
It is possible, the path extractor is just an AWS lambda running the JavaExtractor
on inputs.
There are two services:
The one that you are trying to reach is reachable if I query it directly. Can you try running the following command from the terminal (assuming that you have curl
and running on linux/macos...)?
curl -X POST https://po3g2dx2qa.execute-api.us-east-1.amazonaws.com/production/extractmethods -d '{"code": "public boolean f(Set<String> set, String value) { for (String entry : set) { if (entry.equalsIgnoreCase(value)) { return true ; } } return false; }", "decompose":"true"}'
There is another service that performs the end-to-end prediction, this is the one that the website at code2seq.org uses:
curl -X POST https://djz6amor4b.execute-api.us-east-1.amazonaws.com/prod/predict -d '{"code":"public boolean f(Set<String> set, String value) { for (String entry : set) { if (entry.equalsIgnoreCase(value)) { return true ; } } return false; } "}'
This one is also available and responding. So I'm not sure why it doesn't work for you.
You could implement an option that runs the JavaExtractor locally and takes its output. This is how it is implemented in code2vec: https://github.com/tech-srl/code2vec/blob/master/extractor.py#L12
Let me know how it goes, Uri
I have implemented the extractor (https://github.com/lyriccoder/code_2seq_tf1.2/pull/2). But now I get the error during model prediction:
running java -cp /hdd/code2seq/JavaExtractor/JPredict/target/JavaExtractor-0.0.1-SNAPSHOT.jar JavaExtractor.App --max_path_length 9 --max_path_width 2 --file /tmp/tmp8z8a4udy
and I see the file is correct:
public int f()
{
int a = 0;
return a;
}
self.path_extractor.extract_paths(code)
returns 2 objects, but then pretrained model (downloaded from https://s3.amazonaws.com/code2seq/model/java-large/java-large-model.tar.gz ) cannot predict at all. It fails for any file I pass.@urialon Could you please tell me whether you can help. I understand, that it takes time. Let me know if you won't answer (you do not have time for it)
Hey, First, I want to see why the existing code doesn't work for you.
Did running
curl -X POST https://po3g2dx2qa.execute-api.us-east-1.amazonaws.com/production/extractmethods -d '{"code": "public boolean f(Set<String> set, String value) { for (String entry : set) { if (entry.equalsIgnoreCase(value)) { return true ; } } return false; }", "decompose":"true"}'
work for you? If so, I wonder why it works from the terminal and not from the python code.
It works for your code from terminal.
1) Unfortunately, I cannot send any http requests from python (due to limitation of the network), that's why I have to reimplement it without http requests, just for evaluating the model (couple of examples) 2) It didn't work for java code I passed. Seems the service cannot respond if the Java method is too long
What if you called curl
from python?
that is, instead of requests.post
use something like
subprocess.Popen(['curl', '-x', 'POST', 'https://po3g2dx2qa...', ...], ...)
Would that work?
On Fri, Sep 24, 2021 at 9:20 AM lyriccoder @.***> wrote:
It works for your code from terminal.
- Unfortunately, I cannot send any http requests from python (due to limitation of the network), that's why I have to reimplement it without http requests, just for evaluating the model (couple of examples)
- It didn't work for java code I passed. Seems the service cannot respond if the Java method is too long
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tech-srl/code2seq/issues/103#issuecomment-926619349, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSOXMD33RYICQDKN2M5WGTUDR3JZANCNFSM5ET27UJQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Thanks, @urialon. It works. Now i can compare the response and the results of extract_paths
with jar.
Thank you for help
I'm closing issue, I am using code2vec model. Thank you for help
Hi @lyriccoder , Just be aware that code2seq is much better than code2vec. It has much better encoder and decoder.
@urialon thank you for information, but I can't use functionality with http requests. And rewriting it will take too much time for me.
Thank you for sharing your code!
Could you please tell me what you are doing in the procedure where you post an http request to Amazon service (
InteractivePredictor
)? The request is sent here:I get timeout error every time:
Task timed out after 19.02 seconds
.Where can I get that code? I tried to use JExtractor but it returns not a json format