Skip to content

Commit 8d608fe

Browse files
committed
pycompss_dummy
1 parent 36b84e5 commit 8d608fe

12 files changed

Lines changed: 498 additions & 3 deletions

File tree

src/dataclay/contrib/modeltest/compss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from pycompss.api.parameter import CONCURRENT, INOUT
99
from pycompss.api.task import task
1010
except ImportError:
11-
from dataclay.contrib.dummy_pycompss import task, INOUT, CONCURRENT
11+
from dataclay.contrib.pycompss_dummy.dummy_pycompss import task, INOUT, CONCURRENT
1212

1313
from dataclay import DataClayObject, activemethod
1414

src/dataclay/contrib/persistent_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pycompss.api.task import task
1111
from pycompss.api.parameter import IN
1212
except ImportError:
13-
from dataclay.contrib.dummy_pycompss import task, IN
13+
from dataclay.contrib.pycompss_dummy.dummy_pycompss import task, IN
1414

1515

1616
class PersistentBlock(DataClayObject):
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright 2002-2026 Barcelona Supercomputing Center (www.bsc.es)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# -*- coding: utf-8 -*-
19+
20+
"""This package contains the API dummy functions, constants and classes."""
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright 2002-2026 Barcelona Supercomputing Center (www.bsc.es)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# -*- coding: utf-8 -*-
19+
20+
"""
21+
PyCOMPSs API - dummy - decorator.
22+
23+
This file contains the dummy class task used as decorator.
24+
"""
25+
26+
from pycompss.util.typing_helper import typing
27+
28+
29+
class _Dummy:
30+
"""Dummy task class (decorator style)."""
31+
32+
def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
33+
"""Construct a dummy Task decorator.
34+
35+
:param args: Task decorator arguments.
36+
:param kwargs: Task decorator keyword arguments.
37+
:returns: None
38+
"""
39+
self.args = args
40+
self.kwargs = kwargs
41+
42+
def __call__(self, function: typing.Any) -> typing.Any:
43+
"""Invoke the dummy decorator.
44+
45+
:param function: Decorated function.
46+
:returns: Result of executing the given function.
47+
"""
48+
49+
def wrapped_f(*args: typing.Any, **kwargs: typing.Any) -> typing.Any:
50+
# returns may appear in @task decorator
51+
if "returns" in kwargs:
52+
kwargs.pop("returns")
53+
return function(*args, **kwargs)
54+
55+
return wrapped_f
56+
57+
def __repr__(self) -> str:
58+
attributes = f"(args: {repr(self.args)}, kwargs: {repr(self.kwargs)})"
59+
return f"Dummy {self.__class__.__name__} decorator {attributes}"
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright 2002-2026 Barcelona Supercomputing Center (www.bsc.es)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# -*- coding: utf-8 -*-
19+
20+
"""
21+
PyCOMPSs - dummy - api.
22+
23+
This file defines the public PyCOMPSs API functions without functionality.
24+
"""
25+
26+
import os
27+
28+
from pycompss.util.typing_helper import typing
29+
30+
31+
def compss_start(
32+
log_level: str = "off", # pylint: disable=unused-argument
33+
tracing: bool = False, # pylint: disable=unused-argument
34+
interactive: bool = False, # pylint: disable=unused-argument
35+
disable_external: bool = False, # pylint: disable=unused-argument
36+
) -> None: # pylint: disable=unused-argument
37+
"""Start runtime dummy.
38+
39+
Does nothing.
40+
41+
:param log_level: Log level [ True | False ].
42+
:param tracing: Activate or disable tracing.
43+
:param interactive: Boolean if interactive (ipython or jupyter).
44+
:param disable_external: To avoid to load compss in external process.
45+
:return: None
46+
"""
47+
48+
49+
def compss_stop(
50+
code: int = 0, _hard_stop: bool = False # pylint: disable=unused-argument
51+
) -> None:
52+
"""Stop runtime dummy.
53+
54+
Does nothing.
55+
56+
:param code: Stop code.
57+
:param _hard_stop: Stop COMPSs when runtime has died.
58+
:return: None
59+
"""
60+
61+
62+
def compss_file_exists(
63+
*file_name: typing.Union[list, tuple, str],
64+
) -> typing.Union[bool, typing.List[typing.Union[bool, list]]]:
65+
"""Check if one or more files used in task exists dummy.
66+
67+
Check if the file/s exists.
68+
69+
:param file_name: The file/s name to check.
70+
:return: True if exists. False otherwise.
71+
"""
72+
ret = [] # type: typing.List[typing.Union[bool, list]]
73+
for f_name in file_name:
74+
if isinstance(f_name, (list, tuple)):
75+
ret.append([compss_file_exists(name) for name in f_name])
76+
else:
77+
ret.append(os.path.exists(f_name))
78+
if len(ret) == 1:
79+
return ret[0]
80+
return ret
81+
82+
83+
def compss_open(file_name: str, mode: str = "r") -> typing.Any:
84+
"""Open a file used in task dummy.
85+
86+
Open the given file with the defined mode (see builtin open).
87+
88+
:param file_name: The file name to open.
89+
:param mode: Open mode. Options = [w, r+ or a, r or empty]. Default=r.
90+
:return: An object of "file" type.
91+
:raise IOError: If the file can not be opened.
92+
"""
93+
return open(file_name, mode) # pylint: disable=unspecified-encoding
94+
95+
96+
def compss_delete_file(
97+
*file_name: typing.Union[list, tuple, str],
98+
) -> typing.Union[bool, typing.List[typing.Union[bool, list]]]:
99+
"""Delete one or more files used in task dummy.
100+
101+
Does nothing and always return True.
102+
103+
:param file_name: File/s name.
104+
:return: Always True.
105+
"""
106+
ret = [] # type: typing.List[typing.Union[bool, list]]
107+
for f_name in file_name:
108+
if isinstance(f_name, (list, tuple)):
109+
ret.append([compss_delete_file(name) for name in f_name])
110+
else:
111+
ret.append(True)
112+
if len(ret) == 1:
113+
return ret[0]
114+
return ret
115+
116+
117+
def compss_wait_on_file(
118+
*file_name: typing.Union[list, tuple, str],
119+
) -> typing.Union[list, tuple, str]:
120+
"""Wait on file used in task dummy.
121+
122+
Does nothing.
123+
124+
:param file_name: File/s name.
125+
:return: The files/s name.
126+
"""
127+
if len(file_name) == 1:
128+
return file_name[0]
129+
return file_name
130+
131+
132+
def compss_wait_on_directory(
133+
*directory_name: typing.Union[list, tuple, str],
134+
) -> typing.Union[list, tuple, str]:
135+
"""Wait on directory used in task dummy.
136+
137+
Does nothing.
138+
139+
:param directory_name: Directory/ies name.
140+
:return: The directory/ies name.
141+
"""
142+
if len(directory_name) == 1:
143+
return directory_name[0]
144+
return directory_name
145+
146+
147+
def compss_delete_object(
148+
*objs: typing.Any,
149+
) -> typing.Union[bool, typing.List[typing.Union[bool, list]]]:
150+
"""Delete one or more objects used in task dummy.
151+
152+
Does nothing and always return True.
153+
154+
:param objs: Object/s to delete.
155+
:return: Always True.
156+
"""
157+
ret = [] # type: typing.List[typing.Union[bool, list]]
158+
for obj in objs:
159+
if isinstance(obj, (list, tuple)):
160+
ret.append([compss_delete_object(elem) for elem in obj])
161+
else:
162+
ret.append(True)
163+
if len(ret) == 1:
164+
return ret[0]
165+
return ret
166+
167+
168+
def compss_barrier(
169+
no_more_tasks: bool = False, # pylint: disable=unused-argument
170+
) -> None:
171+
"""Wait for all submitted tasks dummy.
172+
173+
Does nothing.
174+
175+
:param no_more_tasks: No more tasks boolean.
176+
:return: None
177+
"""
178+
179+
180+
def compss_barrier_group(
181+
group_name: str, # pylint: disable=unused-argument
182+
) -> None:
183+
"""Wait for all submitted tasks of a group dummy.
184+
185+
Does nothing.
186+
187+
:param group_name: Name of the group.
188+
:return: None
189+
"""
190+
191+
192+
def compss_cancel_group(
193+
group_name: str, # pylint: disable=unused-argument
194+
) -> None:
195+
"""Cancel all submitted tasks of a group dummy.
196+
197+
Does nothing.
198+
199+
:param group_name: Name of the group.
200+
:return: None
201+
"""
202+
203+
204+
def compss_snapshot() -> None:
205+
"""Request a snapshot.
206+
207+
Does nothing.
208+
209+
:return: None
210+
"""
211+
212+
213+
def compss_wait_on(
214+
*args: typing.Any, **kwargs: typing.Any # pylint: disable=unused-argument
215+
) -> typing.Any:
216+
"""Synchronize an object used in task dummy.
217+
218+
Does nothing.
219+
220+
:param args: Objects to wait on.
221+
:param kwargs: Options dictionary.
222+
:return: The same objects defined as parameter.
223+
"""
224+
ret = list(map(lambda o: o, args))
225+
if len(ret) == 1:
226+
return ret[0]
227+
return ret
228+
229+
230+
def compss_set_wall_clock(
231+
wall_clock_limit: int, # pylint: disable=unused-argument
232+
) -> None:
233+
"""Set the application wall_clock_limit dummy.
234+
235+
Does nothing.
236+
237+
:param wall_clock_limit: Wall clock limit in seconds.
238+
:return: None
239+
"""
240+
241+
242+
class TaskGroup:
243+
"""Dummy TaskGroup context manager."""
244+
245+
def __init__(
246+
self, group_name: str, implicit_barrier: bool = True
247+
) -> None: # pylint: disable=unused-argument
248+
"""Define a new group of tasks.
249+
250+
:param group_name: Group name.
251+
:param implicit_barrier: Perform implicit barrier.
252+
"""
253+
254+
def __enter__(self) -> None:
255+
"""Do nothing.
256+
257+
:return: None
258+
"""
259+
260+
def __exit__(
261+
self,
262+
type: typing.Any, # pylint: disable=redefined-builtin
263+
value: typing.Any,
264+
traceback: typing.Any,
265+
) -> None:
266+
"""Do nothing.
267+
268+
:return: None
269+
"""
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright 2002-2026 Barcelona Supercomputing Center (www.bsc.es)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# -*- coding: utf-8 -*-
19+
20+
"""
21+
PyCOMPSs API - dummy - constraint.
22+
23+
This file contains the dummy class constraint used as decorator.
24+
"""
25+
26+
from pycompss.api.dummy._decorator import _Dummy as Dummy
27+
28+
Constraint = Dummy # pylint: disable=invalid-name
29+
constraint = Dummy # pylint: disable=invalid-name

0 commit comments

Comments
 (0)