Skip to content

Commit

Permalink
cron example nits (#354)
Browse files Browse the repository at this point in the history
* add readable test

* upd

* add error checking for example to deliver worklist

* upd

* upd

* upd

* add clarification

* conform with 4 space spacing in python code

* upd
  • Loading branch information
bensonlee5 authored Aug 31, 2024
1 parent 3b64896 commit 3118750
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions docs/sdk/markdowns/AgentModelsAndMethods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -286,29 +286,30 @@ def execute(**kwargs) -> UploadFileParams | None:

agent_variables = kwargs.get('agent_variables', {})
if not agent_variables:
info('Connection requires parent_dir and file_to_watch to be specified.')
return None
info('Connection requires parent_dir and file_to_watch to be specified.')
return None

# grab watch_dir, filename, recency_min, and recency_max from variables configurable in UI
watch_dir = agent_variables.get('parent_dir', None)
filename = agent_variables.get('file_to_watch', None)
recency_min = float(agent_variables.get('recency_min', 0))
recency_max = float(agent_variables.get('recency_max', 3600))

if watch_dir and filename:
full_file_path = Path(watch_dir) / Path(filename)

if not full_file_path.is_file():
error(f'File {full_file_path} does not exist')
return None
full_file_path = Path(watch_dir) / Path(filename)
if not full_file_path.is_file():
error(f'File {full_file_path} does not exist')
return None
else:
info('Connection requires parent_dir and file_to_watch to be specified.')
return None
info('Connection requires parent_dir and file_to_watch to be specified.')
return None

elapsed_time = time.time() - os.stat(file_path).st_mtime
if elapsed_time >= recency_min and elapsed_time < recency_max:
if not os.access(full_file_path, os.R_OK):
error(f'Do not have read permissions for file {full_file_path}')
return None
if not os.access(full_file_path, os.R_OK):
error(f'Do not have read permissions for file {full_file_path}')
return None

new_file_param = FileParam(filename=str(full_file_path), body=body)

Expand Down

0 comments on commit 3118750

Please sign in to comment.