如何在python脚本中识别正在运行的命令

如何在python脚本中识别正在运行的命令,python,Python,我被指派在prod中调试一个长期运行的python脚本。这里的问题是脚本中没有打印或调试命令。希望检查python是否维护内部日志记录,以便跟踪当前正在运行的命令 e、 g。 下面是我当前的脚本。在这里,该位置有大量文件,并且进程正在为每个文件运行。该脚本已运行了14个小时,我无法找到当前正在运行的命令。因此,维护当前正在运行的命令的任何内部python日志在这里都会有所帮助。我只是需要有关日志文件目录的帮助,或者如何找到这样的日志文件目录 ... # Read data for fna

我被指派在prod中调试一个长期运行的python脚本。这里的问题是脚本中没有打印或调试命令。希望检查python是否维护内部日志记录,以便跟踪当前正在运行的命令

e、 g。 下面是我当前的脚本。在这里,该位置有大量文件,并且进程正在为每个文件运行。该脚本已运行了14个小时,我无法找到当前正在运行的命令。因此,维护当前正在运行的命令的任何内部python日志在这里都会有所帮助。我只是需要有关日志文件目录的帮助,或者如何找到这样的日志文件目录

    ...
# Read data
for fname in glob('<location>*'):
        df = pd.read_csv(fname,header=None,sep=',')
        #here needs to modify the trigger feature every time
        df.columns = [colnames]
        df = df[df.cps_count>0].replace(r'\s+',np.nan,regex=True).replace('\\N',np.nan)
        # df = df[df.cps_count>0].replace(r'\s+',np.nan,regex=True).replace('\\N',np.nan)
        df = pd.get_dummies(df,columns=['prim_ppt']).fillna(np.nan)
        cols_obj = df.columns[df.dtypes.eq('object')]
        df[cols_obj] = df[cols_obj].apply(pd.to_numeric, errors='coerce')
        #this = pd.concat([ids.reset_index()for i in np.setdiff1d(cols,df.columns):df[i] = 0,pd.DataFrame(scores)],axis=1)
        xref_ids = df['cust_xref_id']
        for i in np.setdiff1d(cols,df.columns):df[i] = 0
    #xre_id needs to be replaced
        #feature_importance also needs to be replaced
        feature_importance = model.predict(xgb.DMatrix(df[[i for i in cols]],df['res'],missing=np.nan),pred_contribs=True)
        combined=np.c_[feature_importance,xref_ids]
        df_result=pd.DataFrame(combined,columns=cols+['bias_term','cust_xref_id'])
        dfs.append(df_result)
final= pd.concat(dfs,axis=0)
#need to adjust for every model
df_result2=final[[colnames]]
#need to adjust for every model
df_rank=df_result2[[<somecolnames>]].rank(axis=1,method='first',numeric_only=None,na_option='keep',ascending=False,pct=False)
df_rank['cust_xref_id']=df_result2['cust_xref_id']
#drop the null cust_xref_id
df_rank=df_rank[df_rank['cust_xref_id'].notnull()]
df_rank['cust_xref_id']=df_rank['cust_xref_id'].astype('int')
#Data transformation
#transform from wide to long type
df_final=pd.melt(df_rank,id_vars=['cust_xref_id'],value_vars=[<somecolnames>])
df_final = df_final.sort_values(by=["cust_xref_id", "variable"])
#Note: output file has to be tab seperated -- according to Sahil from CSP core team
if not os.path.exists('<outputPath>'):
        os.makedirs('<outputPath')
df_final.to_csv('<outputfile>',index=None,header=None,sep='\t')
。。。
#读取数据
对于全局('*')中的fname:
df=pd.read_csv(fname,header=None,sep=',')
#这里每次都需要修改触发器功能
df.columns=[colnames]
df=df[df.cps_count>0]。替换(r'\s+',np.nan,regex=True)。替换('\\N',np.nan)
#df=df[df.cps_count>0]。替换(r'\s+',np.nan,regex=True)。替换('\\N',np.nan)
df=pd.get\u dummies(df,columns=['prim\u ppt']).fillna(np.nan)
cols_obj=df.columns[df.dtypes.eq('object')]
df[cols_obj]=df[cols_obj]。应用(pd.to_numeric,errors='concure')
#this=pd.concat([id.reset_index(),用于np.setdiff1d(cols,df.columns)中的i):df[i]=0,pd.DataFrame(scores)],axis=1)
外部参照标识=df['cust\u xref\u id']
对于np.setdiff1d(cols,df.columns)中的i:df[i]=0
#需要更换xre_id
#功能的重要性也需要更换
特征重要性=模型预测(xgb.DMatrix(df[[i代表cols中的i]],df['res'],missing=np.nan),pred\u contribs=True)
组合=np.c \[特征重要性,外部参照ID]
df_result=pd.DataFrame(组合,列=cols+['bias_term','cust_xref_id'])
dfs.append(df_结果)
最终=局部固结(dfs,轴=0)
#需要针对每个型号进行调整
df_result2=final[[colnames]]
#需要针对每个型号进行调整
df_rank=df_result2[[]]。rank(axis=1,method='first',numeric_only=None,na_option='keep',升序=False,pct=False)
df_rank['cust_xref_id']=df_result2['cust_xref_id']
#删除空的cust\u xref\u id
df_rank=df_rank[df_rank['cust_xref_id'].notnull()
df_rank['cust_xref_id']=df_rank['cust_xref_id'].astype('int')
#数据转换
#从宽型到长型的转换
df_final=pd.melt(df_rank,id_vars=['cust\u xref\u id'],value_vars=[]))
df_final=df_final.sort_值(按=[“客户外部参照id”,“变量”])
#注:根据CSP核心团队的Sahil,输出文件必须用制表符分隔
如果操作系统路径不存在(“”):

os.makedirs('您根本无法编辑该文件?