Closed Mokita-J closed 7 months ago
A modification step is necessary before executing the main.py
You need to enter the antlr4
package and find the RuleContext.py
and Trees.py
(Some IDEs such as PyCharm can implement this process).
Add the method code below in the RuleContext
class in RuleContext.py
.
def toCodeSequence(self, ruleNames:list=None, recog:Parser=None):
return Trees.toCodeSequence(self, ruleNames=ruleNames, recog=recog)
Add the method code below in the Trees
class in Trees.py
.
@classmethod
def toCodeSequence(cls, t:Tree, ruleNames:list=None, recog:Parser=None):
if recog is not None:
ruleNames = recog.ruleNames
s = escapeWhitespace(cls.getNodeText(t, ruleNames), False)
if t.getChildCount()==0:
return s
with StringIO() as buf:
buf.write(s)
buf.write(' ')
for i in range(0, t.getChildCount()):
if i > 0:
buf.write(' ')
buf.write(cls.toCodeSequence(t.getChild(i), ruleNames))
return buf.getvalue()
Thanks for the info! I got through the first training epochs.
But I can't still complete the training. This is the error I get:
Traceback (most recent call last):
File "main.py", line 72, in <module>
loss = model(batch[:-1], True, batch[-1])
File "/RLRep/.venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/RLRep/multistep_RLRep.py", line 388, in forward
return self.train_on_batch(inputs, contracts)
File "/RLRep/multistep_RLRep.py", line 410, in train_on_batch
res = choose_action(contracts[i], preds[i], True)
File "/RLRep/utils2.py", line 708, in choose_action
rew = fitness_function2(contract_path, repair_path)
File "/RLRep/utils2.py", line 101, in fitness_function2
contract_sims = get_similarity(original_contract, first=False)
File "/RLRep/similarity_compute.py", line 66, in get_similarity
context1_npy = np.load(context1_npy_path)
File "/RLRep/.venv/lib/python3.8/site-packages/numpy/lib/npyio.py", line 417, in load
fid = stack.enter_context(open(os_fspath(file), "rb"))
FileNotFoundError: [Errno 2] No such file or directory: 'FastText/bugEmbedding/0context1.npy'
It seems I am missing some files to calculate the similarity. Any suggestions to surpass this error?
Thx for the help!
Download the corresponding files from Zenodo. Please refer to Readme file.
Great! Thanks for the prompt reply
But there are still some missing files like: solidity-extractor/function.js
this file is needed according to this line.
This is the error I encounter during training:
Node.js v20.12.0
node:internal/modules/cjs/loader:1146
throw err;
^
Error: Cannot find module '/home/mokita/sc_study/RLRep/solidity-extractor/function.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
at Module._load (node:internal/modules/cjs/loader:984:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Thanks for all the help so far! RLRep is a really cool tool, can't wait to test it out :)
The corresponding files are updated.
Hey!
I followed the usage instructions provided in the README but I can't seem to run main.py like suggested. This is the error:
Could you provide some insights on this matter? Thx!