Skip to content

Commit

Permalink
🏅 multiprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
raynardj committed Nov 28, 2021
1 parent a705489 commit a6ec957
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion forgebox/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.18.2"
__version__ = "0.4.18.3"
2 changes: 1 addition & 1 deletion forgebox/multiproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __iter__(self):

def __getitem__(self, idx):
global DataFrameRowling_df
return DataFrameRowling_df[DataFrameRowling_df.index[idx]]
return DataFrameRowling_df[list(DataFrameRowling_df.index[idx]]

def __next__(self):
global DataFrameRowling_df
Expand Down
29 changes: 25 additions & 4 deletions nbs/09_multiprocess.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
},
{
"cell_type": "code",
"execution_count": 59,
"execution_count": 60,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -204,7 +204,7 @@
" \n",
" def __getitem__(self, idx):\n",
" global DataFrameRowling_df\n",
" return DataFrameRowling_df[DataFrameRowling_df.index[idx]]\n",
" return DataFrameRowling_df[list(DataFrameRowling_df.index)[idx]]\n",
" \n",
" def __next__(self):\n",
" global DataFrameRowling_df\n",
Expand All @@ -216,7 +216,7 @@
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": 61,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -226,13 +226,34 @@
},
{
"cell_type": "code",
"execution_count": 57,
"execution_count": 62,
"metadata": {},
"outputs": [],
"source": [
"res = Parallel(backend=\"multiprocessing\", n_jobs=6)(delayed(get_line)(i) for i in DataFrameRowling(df))"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"col1 5\n",
"Name: 5, dtype: int64"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res[5]"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ author = xiaochen(ray) zhang
author_email = [email protected]
copyright = xiaochen(ray) zhang
branch = master
version = 0.4.18.2
version = 0.4.18.3
min_python = 3.6
audience = Developers
language = English
Expand Down

0 comments on commit a6ec957

Please sign in to comment.