Skip to content

Commit 9723fb8

Browse files
committed
Documentation improvements
1 parent 8ba65a1 commit 9723fb8

File tree

8 files changed

+151
-28
lines changed

8 files changed

+151
-28
lines changed

.github/workflows/create-prerelease.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: |
3232
echo "::set-output name=version::$(date +'%Y-%m-%d' --utc)"
3333
-
34-
name: Create Stable Release
34+
name: Create Pre-Release
3535
id: create_release
3636
uses: actions/create-release@v1
3737
env:

parsoda/model/function/analyzer.py

+11
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,15 @@ class Analyzer(ABC, Generic[K, R, A]):
1515

1616
@abstractmethod
1717
def analyze(self, driver: ParsodaDriver, data: Dict[K, R]) -> A:
18+
"""Applies an analysis algorithm to the output data from reduction step.
19+
The analyzer might be a sequential, parallel or distributed algorithm.
20+
In the latter case, the algorithm would use the same driver used by the current application for running a new, nested, ParSoDA application.
21+
22+
Args:
23+
driver (ParsodaDriver): the driver used during the execution of the parallel phase
24+
data (Dict[K, R]): output data from reducton step organized as a dictionary of key-value pairs
25+
26+
Returns:
27+
A: the outputdata type from the analysis
28+
"""
1829
pass

parsoda/model/function/crawler.py

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ def get_partitions(self, num_of_partitions=0, partition_size=1024*1024*1024) ->
6464

6565
@abstractmethod
6666
def supports_remote_partitioning(self) -> bool:
67+
"""Checks if the crawler supports remote partitioning, i.e. the ability to read data directly from the worker nodes
68+
69+
Returns:
70+
bool: true if the crawler supports remote partitionig of data source.
71+
"""
6772
pass
6873

6974

parsoda/model/function/filter.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ class Filter(ABC):
1010

1111
@abstractmethod
1212
def test(self, item: SocialDataItem) -> bool:
13-
"""
14-
Test if the item satisfies the predicate of the filter
15-
:param item: the item to test
16-
:return: True if the item satisfies the predicate, False otherwise
17-
"""
13+
"""Test if the item satisfies the predicate of the filter
14+
15+
Args:
16+
item (SocialDataItem): the item to test
17+
18+
Returns:
19+
bool: True if the item satisfies the predicate, False otherwise
20+
"""
1821
pass

parsoda/model/function/mapper.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ class Mapper(ABC, Generic[K, V]):
1414

1515
@abstractmethod
1616
def map(self, item: SocialDataItem) -> Iterable[Tuple[K, V]]:
17-
"""
18-
Returns a list of key-value pairs computed from the given item.
17+
"""Returns a list of key-value pairs computed from the given item.
1918
Example result: [ (item.user_id, item.tags[0]), (item.user_id, item.tags[1]), ... ]
20-
:param item: the item to map
21-
:return: a list of key-value pairs
19+
20+
Args:
21+
item (SocialDataItem): the item to map
22+
23+
Returns:
24+
Iterable[Tuple[K, V]]: an iterable of key-value pairs
2225
"""
2326
pass

parsoda/model/function/reducer.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ class Reducer(ABC, Generic[K, V, R]):
1212
"""
1313

1414
def reduce(self, key: K, values: List[V]) -> R:
15-
"""
16-
Applies the reduction algorithm to values
17-
:param key: the key all values are associated to
18-
:param values: all the values associated to the key
19-
:return: the reduced value
15+
"""Applies the reduction algorithm to values
16+
17+
Args:
18+
key (K): the key all values are associated to
19+
values (List[V]): all the values associated to the key
20+
21+
Returns:
22+
R: the reduced value
2023
"""
2124
pass

parsoda/model/function/visualizer.py

+5
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ class Visualizer(ABC, Generic[A]):
1111

1212
@abstractmethod
1313
def visualize(self, result: A) -> None:
14+
"""Transforms data from the analysis step in some output format, then write them to some output device or system.
15+
16+
Args:
17+
result (A): the data resulting from the analysis step
18+
"""
1419
pass

parsoda/model/social_data_app.py

+106-13
Original file line numberDiff line numberDiff line change
@@ -44,49 +44,124 @@ def __init__(
4444

4545
self.__reduce_result_length = reduce_result_length
4646

47-
def get_app_name(self):
47+
def get_app_name(self)->str:
48+
"""Gets the referred application name
49+
50+
Returns:
51+
str: the app name
52+
"""
4853
return self.__app_name
4954

50-
def get_driver(self):
55+
def get_driver(self)->ParsodaDriver:
56+
"""Gets the driver used by the application
57+
58+
Returns:
59+
ParsodaDriver: the driver object
60+
"""
5161
return self.__driver
5262

53-
def get_partitions(self):
63+
def get_partitions(self)->int:
64+
"""Gets the number of partitions used during execution
65+
66+
Returns:
67+
int: number of partitions
68+
"""
5469
return self.__partitions
5570

56-
def get_chunk_size(self):
71+
def get_chunk_size(self)->int:
72+
"""Gets the data chunk size, i.e. the partitoin size, used during execution
73+
74+
Returns:
75+
int: data chunck size
76+
"""
5777
return self.__chunk_size
5878

59-
def get_crawling_time(self):
79+
def get_crawling_time(self)->float:
80+
"""Gets the time spent on crawling
81+
82+
Returns:
83+
float: the crawling time in seconds
84+
"""
6085
return self.__crawling_time
6186

62-
def get_filter_time(self):
87+
def get_filter_time(self)->float:
88+
"""Gets the time spent on filtering
89+
90+
Returns:
91+
float: the filter time in seconds
92+
"""
6393
return self.__filter_time
6494

65-
def get_map_time(self):
95+
def get_map_time(self)->float:
96+
"""Gets the time spent on mapping
97+
98+
Returns:
99+
float: the map time in seconds
100+
"""
66101
return self.__map_time
67102

68-
def get_split_time(self):
103+
def get_split_time(self)->float:
104+
"""Gets the time spent on splitting
105+
106+
Returns:
107+
float: the split time in seconds
108+
"""
69109
return self.__split_time
70110

71-
def get_reduce_time(self):
111+
def get_reduce_time(self)->float:
112+
"""Gets the time spent on reduction
113+
114+
Returns:
115+
float: the reduce time in seconds
116+
"""
72117
return self.__reduce_time
73118

74-
def get_analysis_time(self):
119+
def get_analysis_time(self)->float:
120+
"""Gets the time spent on analysis
121+
122+
Returns:
123+
float: the analysis time in seconds
124+
"""
75125
return self.__analysis_time
76126

77-
def get_visualization_time(self):
127+
def get_visualization_time(self)->float:
128+
"""Gets the time spent on visualization
129+
130+
Returns:
131+
float: the visualization time in seconds
132+
"""
78133
return self.__visualization_time
79134

80-
def get_total_execution_time(self):
135+
def get_parallel_execution_time(self)->float:
136+
"""Gets the time spent on parallel execution, i.e. the time spent from filtering to reduction.
137+
138+
Returns:
139+
float: the parallel execution time
140+
"""
81141
return self.__filter_to_reduce_time
82142

83-
def get_total_execution_time(self):
143+
def get_total_execution_time(self)->float:
144+
"""Gets the time spent on execution, from filtering to visualization, excluding the crawling step
145+
146+
Returns:
147+
float: the total execution time in seconds
148+
"""
84149
return self.__total_execution_time
85150

86151
def get_total_time(self):
152+
"""Gets the total time spent for completing the application, from crawling to visualization, i.e. the response time
153+
154+
Returns:
155+
float: the total response time
156+
"""
87157
return self.__total_time
88158

89159
def get_reduce_result_length(self):
160+
"""Gets the number of items obtained by executing the reduction. This value can be used for debbugging purposes and for testing the correctness of the parallel execution.
161+
162+
Returns:
163+
float: the length of the reduction result
164+
"""
90165
return self.__reduce_result_length
91166

92167
def __repr__(self):
@@ -117,6 +192,14 @@ def __str__(self):
117192
"| Reduce result length: " + str(self.__reduce_result_length) + "\n"
118193

119194
def to_csv_line(self, separator: str = ";") -> str:
195+
"""Creates a CSV (Comma Separated Value) line for this report, by using the specified separator
196+
197+
Args:
198+
separator (str, optional): The values separator. Defaults to ";".
199+
200+
Returns:
201+
str: the CSV line
202+
"""
120203
return \
121204
str(self.__app_name)+separator+\
122205
str(self.__partitions)+separator+\
@@ -134,6 +217,16 @@ def to_csv_line(self, separator: str = ";") -> str:
134217
str(self.__reduce_result_length)
135218

136219
def to_csv_titles(self, separator: str = ";") -> str:
220+
"""Creates a CSV (Comma Separated Value) header line, by using the specified separator.
221+
The returned line contains just the standard titles of report columns.
222+
It can be used for writing the first header line of a CSV file that would store more than one execution report.
223+
224+
Args:
225+
separator (str, optional): The values separator. Defaults to ";".
226+
227+
Returns:
228+
str: the columns titles in a CSV line
229+
"""
137230
return \
138231
"App Name"+separator+\
139232
"Partitions"+separator+\

0 commit comments

Comments
 (0)