Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
637fd6ce
Commit
637fd6ce
authored
Nov 04, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
a594fcd6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
13 deletions
+2
-13
dist_update_user_portrait_service.py
eda/smart_rank/dist_update_user_portrait_service.py
+2
-13
No files found.
eda/smart_rank/dist_update_user_portrait_service.py
View file @
637fd6ce
...
@@ -77,14 +77,8 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
...
@@ -77,14 +77,8 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
gmkv_tag_score_sum
=
tag_score_sum
[[
"tag2"
,
"tag_score"
,
"weight"
]][:
size
]
.
to_dict
(
'record'
)
gmkv_tag_score_sum
=
tag_score_sum
[[
"tag2"
,
"tag_score"
,
"weight"
]][:
size
]
.
to_dict
(
'record'
)
gmkv_tag_score2_sum
=
tag_score_sum
[[
"tag2"
,
"tag_score"
]][:
size
]
.
to_dict
(
'record'
)
gmkv_tag_score2_sum
=
tag_score_sum
[[
"tag2"
,
"tag_score"
]][:
size
]
.
to_dict
(
'record'
)
gmkv_tag_score2_sum_dict
=
{
i
[
"tag2"
]:
i
[
"tag_score"
]
for
i
in
gmkv_tag_score2_sum
}
gmkv_tag_score2_sum_dict
=
{
i
[
"tag2"
]:
i
[
"tag_score"
]
for
i
in
gmkv_tag_score2_sum
}
# 写gmkv
gm_kv_cli
=
redis
.
Redis
(
host
=
"172.16.40.135"
,
port
=
5379
,
db
=
2
,
socket_timeout
=
2000
)
# 写redis
cl_id_portrait_key
=
"user:service_portrait_tags:cl_id:"
+
str
(
cl_id
)
tag_id_list_json
=
json
.
dumps
(
gmkv_tag_score_sum
)
gm_kv_cli
.
set
(
cl_id_portrait_key
,
tag_id_list_json
)
gm_kv_cli
.
expire
(
cl_id_portrait_key
,
time
=
30
*
24
*
60
*
60
)
写
redis
redis_client
=
redis
.
StrictRedis
.
from_url
(
'redis://:ReDis!GmTx*0aN9@172.16.40.173:6379'
)
redis_client
=
redis
.
StrictRedis
.
from_url
(
'redis://:ReDis!GmTx*0aN9@172.16.40.173:6379'
)
cl_id_portrait_key2
=
"user:service_portrait_tags2:cl_id:"
+
str
(
cl_id
)
cl_id_portrait_key2
=
"user:service_portrait_tags2:cl_id:"
+
str
(
cl_id
)
# 如果画像的tag个数小于5,则补充热搜词
# 如果画像的tag个数小于5,则补充热搜词
...
@@ -137,7 +131,6 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
...
@@ -137,7 +131,6 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
try
:
db_jerry_test
=
pymysql
.
connect
(
host
=
'172.16.40.170'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db_jerry_test
=
pymysql
.
connect
(
host
=
'172.16.40.170'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
,
charset
=
'utf8'
)
db
=
'jerry_test'
,
charset
=
'utf8'
)
cur_jerry_test
=
db_jerry_test
.
cursor
()
cur_jerry_test
=
db_jerry_test
.
cursor
()
...
@@ -218,6 +211,3 @@ if __name__ == '__main__':
...
@@ -218,6 +211,3 @@ if __name__ == '__main__':
device_ids_lst_rdd
=
spark
.
sparkContext
.
parallelize
(
device_ids_lst
,
numSlices
=
1000
)
device_ids_lst_rdd
=
spark
.
sparkContext
.
parallelize
(
device_ids_lst
,
numSlices
=
1000
)
result
=
device_ids_lst_rdd
.
repartition
(
100
)
.
map
(
lambda
x
:
get_user_service_portrait
(
x
,
all_word_tags
,
all_tag_tag_type
,
all_3tag_2tag
,
all_tags_name
))
result
=
device_ids_lst_rdd
.
repartition
(
100
)
.
map
(
lambda
x
:
get_user_service_portrait
(
x
,
all_word_tags
,
all_tag_tag_type
,
all_3tag_2tag
,
all_tags_name
))
result
.
collect
()
result
.
collect
()
except
Exception
as
e
:
send_email
(
"dist_update_user_portrait_service"
,
"dist_update_user_portrait_service"
,
"dist_update_user_portrait_service"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment