Skip to content

Commit 4c00dbc

Browse files
committed
fix: Fix "..."obj. has not attr. "id"
- change settings -use tqdm in training - rewrite pipeline
1 parent 55107d6 commit 4c00dbc

399 files changed

Lines changed: 5711084 additions & 1352 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AstToEcoreConverter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ def create_method_signature(self, method_node, name, arguments, return_type = No
11341134

11351135
# Add type for TParameter.type
11361136
parameter_type = self.create_ecore_instance(NodeTypes.CLASS)
1137-
parameter_type.tName = arg.annotation.id if arg.annotation else 'None'
1137+
#parameter_type.tName = arg.annotation if arg.annotation else 'None'
11381138
parameter.type = parameter_type
11391139

11401140
method_node.signature = method_signature
@@ -1239,7 +1239,7 @@ def write_xmi(self, resource_set, output_directory, repository):
12391239
# Replace slashes in the repository name with underscores
12401240
safe_repository_name = repository_name.replace('/', '_').replace('\\', '_')
12411241

1242-
resource = resource_set.create_resource(URI(f'{output_directory}/{safe_repository_name}.xmi'),
1242+
resource = resource_set.create_resource(URI(f'{output_directory}/xmi_files/{safe_repository_name}.xmi'),
12431243
use_uuid=True)
12441244
resource.append(self.graph)
12451245
resource.save()

Pipeline.py

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -95,39 +95,41 @@ def create_ecore_graphs(repository, write_in_file, output_directory=None):
9595
Exception: Any exceptions raised during the graph creation process will be printed,
9696
and the function will skip the problematic repository.
9797
"""
98-
global ecore_graph
99-
skip_counter = 0
100-
resource_set = ResourceSet()
101-
if os.path.isdir(repository):
102-
try:
103-
ecore_graph = ProjectEcoreGraph(
104-
resource_set, repository, write_in_file, output_directory)
105-
except Exception as e:
106-
print(e)
107-
if 'inconsistent use of tabs and spaces in indentation' in str(e):
108-
# format repository files using autopep8
109-
python_files = [os.path.join(root, file) for root, _, files in os.walk(
110-
repository) for file in files if file.endswith('.py')]
111-
for file_path in python_files:
112-
os.system(f'autopep8 --in-place {file_path}')
113-
try:
114-
ecore_graph = ProjectEcoreGraph(
115-
resource_set, repository, write_in_file, output_directory)
116-
except Exception as e:
117-
print(e)
118-
print(f'Problem with repository {repository}. Skipping.')
119-
skip_counter += 1
120-
else:
121-
print(f'Problem with repository {repository}. Skipping.')
122-
skip_counter += 1
123-
else:
98+
if not os.path.isdir(repository):
12499
print(f'Problem with repository {repository}. Skipping.')
125-
skip_counter += 1
126-
if write_in_file is False:
127-
return ecore_graph.get_graph()
128-
else:
129100
return None
130101

102+
resource_set = ResourceSet()
103+
try:
104+
ecore_graph = ProjectEcoreGraph(
105+
resource_set, repository, write_in_file, output_directory)
106+
if write_in_file is False:
107+
return ecore_graph.get_graph()
108+
else:
109+
return None
110+
except Exception as e:
111+
print(e)
112+
if 'inconsistent use of tabs and spaces in indentation' in str(e):
113+
# format repository files using autopep8
114+
python_files = [os.path.join(root, file) for root, _, files in os.walk(
115+
repository) for file in files if file.endswith('.py')]
116+
for file_path in python_files:
117+
os.system(f'autopep8 --in-place {file_path}')
118+
try:
119+
ecore_graph = ProjectEcoreGraph(
120+
resource_set, repository, write_in_file, output_directory)
121+
if write_in_file is False:
122+
return ecore_graph.get_graph()
123+
else:
124+
return None
125+
except Exception as e:
126+
print(e)
127+
print(f'Problem with repository {repository}. Skipping.')
128+
return None
129+
else:
130+
print(f'Problem with repository {repository}. Skipping.')
131+
return None
132+
131133

132134
def create_matrix_structure(write_in_file, xmi_file=None, local_ecore_graph=None, output_directory=None):
133135
"""
@@ -203,8 +205,9 @@ def parallel_processing(func, repository_list):
203205
Exception: Any exceptions raised during the execution of the function
204206
will be propagated.
205207
"""
206-
pool = Pool() # number of processes is return value of os.cpu_count()
207-
pool.starmap(func, repository_list)
208+
with Pool() as pool: # number of processes is return value of os.cpu_count()
209+
results = pool.starmap(func, repository_list)
210+
return results
208211

209212

210213
def prepare_dataset(repository_directory, output_directory=None, repository_list=None):

0 commit comments

Comments
 (0)