fix: Ensure feature layer is truncated at the start of script execution

- Moved the call to the truncate function to always execute at the beginning of the main function.
- Ensured that the feature layer is cleared before loading data from a JSON file or fetching from the API.
This commit is contained in:
Nick Heppler 2025-05-22 12:12:01 -04:00
parent cad8d64c23
commit 3afe292b23

4
app.py
View File

@ -336,10 +336,12 @@ def main():
fs = os.getenv('FS') fs = os.getenv('FS')
layer = os.getenv('LAYER') layer = os.getenv('LAYER')
logger.info("Truncating the feature layer.")
truncate(token, hostname, instance, fs, layer)
# If --reload flag is set, load data from the specified file # If --reload flag is set, load data from the specified file
if reload_file: if reload_file:
logger.info(f"Reloading data from file: {reload_file}") logger.info(f"Reloading data from file: {reload_file}")
truncate(token, hostname, instance, fs, layer) # Truncate the layer
# Load data from the specified file # Load data from the specified file
with open(reload_file, 'r', encoding='utf-8') as f: with open(reload_file, 'r', encoding='utf-8') as f: