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
f11d3e62
Commit
f11d3e62
authored
Aug 15, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change test file
parent
0ecc2a07
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
53 deletions
+30
-53
hello.py
hello.py
+0
-0
keepProcess.py
keepProcess.py
+0
-21
monitor.py
monitor.py
+0
-0
test.py
tensnsorflow/test.py
+30
-32
No files found.
hello.py
View file @
f11d3e62
This diff is collapsed.
Click to expand it.
keepProcess.py
deleted
100644 → 0
View file @
0ecc2a07
import
os
import
time
def
check
():
out
=
os
.
popen
(
"ps aux | grep diaryQueueUpdate.py"
)
.
read
()
flag
=
1
for
line
in
out
.
splitlines
():
if
'python diaryQueueUpdate.py'
in
line
:
flag
=
2
return
flag
if
__name__
==
"__main__"
:
#TODO 正式上线后,把下面的循环和time.sleep打开
# while True:
if
check
()
==
1
:
os
.
popen
(
'python diaryQueueUpdate.py'
)
print
(
"成功重启diaryQueueUpdate"
)
# time.sleep(300)
\ No newline at end of file
monitor.py
0 → 100644
View file @
f11d3e62
This diff is collapsed.
Click to expand it.
tensnsorflow/test.py
View file @
f11d3e62
...
...
@@ -40,39 +40,37 @@ def con_sql(db,sql):
db
.
close
()
return
df
def
write_redis
(
device_id
,
cid_list
):
try
:
db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'eagle'
)
sql
=
"select b.id from src_mimas_prod_api_diary_tags a left join src_zhengxing_api_tag b "
\
"on a.tag_id = b.id where b.tag_type = '3' and a.diary_id in {}"
.
format
(
tuple
(
cid_list
))
cursor
=
db
.
cursor
()
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
tags
=
list
(
set
([
i
[
0
]
for
i
in
result
]))
if
tags
is
not
None
:
sql
=
"select a.id from src_mimas_prod_api_diary a left join src_mimas_prod_api_diary_tags b "
\
"on a.id=b.diary_id left join src_zhengxing_api_tag c on b.tag_id=c.id "
\
"where a.is_online = 1 and a.content_level >= '3' "
\
"and c.id in {} and c.tag_type = '3'"
.
format
(
tuple
(
tags
))
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
cids
=
list
(
set
([
i
[
0
]
for
i
in
result
]))
r
=
redis
.
StrictRedis
.
from_url
(
'redis://:ReDis!GmTx*0aN6@172.16.40.133:6379'
)
key
=
str
(
device_id
)
+
"_dislike"
if
r
.
exists
(
key
):
cids
=
json
.
dumps
(
list
(
set
(
eval
(
r
.
get
(
key
))
.
extend
(
cids
))))
r
.
set
(
key
,
json
.
dumps
(
cids
))
except
e
:
print
(
"insert redis fail"
)
print
(
e
)
if
__name__
==
'__main__'
:
# sparkConf = SparkConf().set("spark.hive.mapred.supports.subdirectories", "true") \
# .set("spark.hadoop.mapreduce.input.fileinputformat.input.dir.recursive", "true") \
# .set("spark.tispark.plan.allow_index_double_read", "false") \
# .set("spark.tispark.plan.allow_index_read", "true") \
# .set("spark.sql.extensions", "org.apache.spark.sql.TiExtensions") \
# .set("spark.tispark.pd.addresses", "172.16.40.158:2379").set("spark.io.compression.codec", "lzf") \
# .set("spark.driver.maxResultSize", "8g")
#
# spark = SparkSession.builder.config(conf=sparkConf).enableHiveSupport().getOrCreate()
# ti = pti.TiContext(spark)
# ti.tidbMapDatabase("jerry_test")
# spark.sparkContext.setLogLevel("WARN")
# sql = "select stat_date,cid_id,y,ccity_name from esmm_train_data limit 60"
# spark.sql(sql).show(6)
sql
=
"select level2_id,concat('t',treatment_method),"
\
"concat('min',price_min),concat('max',price_max),"
\
"concat('tr',treatment_time),concat('m',maintain_time),"
\
"concat('r',recover_time) from jerry_test.train_Knowledge_network_data"
db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
df
=
con_sql
(
db
,
sql
)
df
=
df
.
rename
(
columns
=
{
0
:
"level2_id"
,
1
:
"treatment_method"
,
2
:
"price_min"
,
3
:
"price_max"
,
4
:
"treatment_time"
,
5
:
"maintain_time"
,
6
:
"recover_time"
})
print
(
df
.
head
(
6
))
host
=
'172.16.40.158'
port
=
4000
user
=
'root'
password
=
'3SYz54LS9#^9sBvC'
db
=
'jerry_test'
charset
=
'utf8'
engine
=
create_engine
(
str
(
r"mysql+pymysql://
%
s:"
+
'
%
s'
+
"@
%
s:
%
s/
%
s"
)
%
(
user
,
password
,
host
,
port
,
db
))
df
.
to_sql
(
'knowledge'
,
con
=
engine
,
if_exists
=
'append'
,
index
=
False
,
chunksize
=
8000
)
print
(
"insert done"
)
a
=
[
16713508
,
16708343
,
16480641
,
16877829
,
16813264
,
16204980
]
d
=
"E417C286-40A4-42F6-BDA9-AEEBD8FEC3B6"
write_redis
(
d
,
a
)
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