
    8j                         d dl mZmZ d dlmZ d dlmZmZmZ d dl	Z	d dl
Z
d dlZd dlZd dlmZ  ed          Z G d d	e          Ze                    d
          defd            ZdS )    )FastAPIHTTPException)	BaseModel)ListDictAnyNtransform_rowzAI Land Pipeline API)titlec                   6    e Zd ZU eeeef                  ed<   dS )PipelineRequestraw_dataN)__name__
__module____qualname__r   r   strr   __annotations__     &/var/www/html/banglarbhumi/land_api.pyr   r      s+         4S>""""""r   r   z/land_checkreqc                    t          |            	 d | j        D             }g }t          |          D ]\  }}|                    d          }|                    d          }|L|Jt	          |                                          dk    s%t	          |                                          dk    r|                    |||d           |rdd|dS t          d	d
d          5 }t          j	        ||dd           d d d            n# 1 swxY w Y   t          d           t          j        ddgdd          }t          d           t          |j                   t          d           t          |j                   |j        dk    rt          d|j                  t!          j        d          }	|	st          dd          t#          |	t$          j        j                  }
t          j        dd|
gdd          }|j        dk    rt          d|j                  t          |
dd          5 }t          j        |          }d d d            n# 1 swxY w Y   d}|                                D ] \  }}|                    d          dk    rd} ||
|d S # t.          $ r#}t          dt	          |                    d }~ww xY w)!Nc                 ,    g | ]}t          |          S r   r	   ).0rows     r   
<listcomp>z run_pipeline.<locals>.<listcomp>"   s0     
 
 
 #
 
 
r   JL_NoDaag_No )	row_index	jl_number
dag_numberFz>JL Number or Daag Number is blank in payload, I can not check.)successmessagemissing_recordszformatted_output.jsonwzutf-8)encoding   )indentensure_asciiu!   ✅ formatted_output.json createdpython3zmatch_pipeline.pyT)capture_outputtextzSTDOUT:zSTDERR:r   i  )status_codedetailzgrouped_result_*.jsonzNo grouped result file found)keyzpush_ai_status.pyrstatusREJECTED)r#   grouped_result_filedata)printr   	enumerategetr   stripappendopenjsondump
subprocessrunstdoutstderr
returncoder   globmaxospathgetctimeloaditems	Exception)r   transformed_datar%   idxr   r!   r"   fmatch_resultgrouped_fileslatest_filepush_resultfinal_result
is_success_itemes                    r   run_pipelinerW      s    
#JJJP


 
|
 
 
 !"233 	 	HC((I++J !%y>>''))R//z??((**b00  &&!$!*",( (     	 ![#2   )3AAA 	QI "	   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	1222
 "~+,
 
 
 	il!"""il!""""a''#*    	"9:: 	5   
 -RW-=>>>
 !n#
  
 
 
 !Q&&")    +sW555 	(9Q<<L	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 
#))++ 	 	GAtxx!!Z//"
 "#. 
 
 	
  
 
 
q66
 
 
 	

sg   C J  J  $D	=J  	DJ  DD&J  7IJ  IJ  I ?J   
K*KK)fastapir   r   pydanticr   typingr   r   r   r>   r<   rC   rE   fetch_land_datar
   appr   postrW   r   r   r   <module>r^      s
   * * * * * * * *       " " " " " " " " " "       				 * ) ) ) ) )g*+++# # # # #i # # # -S
o S
 S
 S
 S
 S
 S
r   