Skip to content

Commit 1990e5c

Browse files
committed
added elapsed time to automatic exports
1 parent 5298817 commit 1990e5c

File tree

9 files changed

+32
-14
lines changed

9 files changed

+32
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changelog
22

3-
## 1.9.1 (2025-10-15)
3+
## 1.9.2 (2025-10-16)
44

55
- added `--output-file` argument
6+
- added stack level `exports` - pre defined `stack_name`, `stack_env`, `elapsed_time` and user defined
67
- Added performance enhancement query strategy
78
- Added tab completion
89
- Added enhanced logging decorators

examples/databricks/serverless/outputs/deployment.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"databricks_workspace_id": "4014389171618363",
66
"databricks_deployment_name": "dbc-5a3a87f7-6914",
77
"databricks_workspace_status": "RUNNING",
8-
"databricks_workspace_url": "https://dbc-5a3a87f7-6914.cloud.databricks.com"
8+
"databricks_workspace_url": "https://dbc-5a3a87f7-6914.cloud.databricks.com",
9+
"elapsed_time": "0:00:31.470746"
910
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"stack_name": "stackql-serverless",
3+
"stack_env": "prd",
4+
"databricks_workspace_name": "stackql-serverless-prd-workspace",
5+
"databricks_workspace_id": "4014389171618363",
6+
"databricks_deployment_name": "dbc-5a3a87f7-6914",
7+
"databricks_workspace_status": "RUNNING",
8+
"databricks_workspace_url": "https://dbc-5a3a87f7-6914.cloud.databricks.com",
9+
"elapsed_time": "0:00:18.247444"
10+
}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name='stackql-deploy',
13-
version='1.9.1',
13+
version='1.9.2',
1414
description='Model driven resource provisioning and deployment framework using StackQL.',
1515
long_description=readme,
1616
long_description_content_type='text/x-rst',

stackql_deploy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.9.1'
1+
__version__ = '1.9.2'

stackql_deploy/cmd/base.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def run_command(self, command_query, command_retries, command_retry_delay, dry_r
471471
else:
472472
self.logger.info("command query not configured, skipping command...")
473473

474-
def process_stack_exports(self, dry_run, output_file=None):
474+
def process_stack_exports(self, dry_run, output_file=None, elapsed_time=None):
475475
"""
476476
Process root-level exports from manifest and write to JSON file
477477
"""
@@ -483,18 +483,18 @@ def process_stack_exports(self, dry_run, output_file=None):
483483
manifest_exports = self.manifest.get('exports', [])
484484

485485
if dry_run:
486-
total_vars = len(manifest_exports) + 2 # +2 for stack_name and stack_env
486+
total_vars = len(manifest_exports) + 3 # +3 for stack_name, stack_env, and elapsed_time
487487
self.logger.info(
488488
f"📁 dry run: would export {total_vars} variables to {output_file} "
489-
f"(including automatic stack_name and stack_env)"
489+
f"(including automatic stack_name, stack_env, and elapsed_time)"
490490
)
491491
return
492492

493-
# Collect data from global context
493+
# Collect data in specific order: stack metadata first, user exports, then timing
494494
export_data = {}
495495
missing_vars = []
496496

497-
# Always include stack_name and stack_env automatically
497+
# Always include stack_name and stack_env automatically as first exports
498498
export_data['stack_name'] = self.stack_name
499499
export_data['stack_env'] = self.stack_env
500500

@@ -522,6 +522,10 @@ def process_stack_exports(self, dry_run, output_file=None):
522522
self.logger
523523
)
524524

525+
# Add elapsed_time as the final automatic export
526+
if elapsed_time is not None:
527+
export_data['elapsed_time'] = str(elapsed_time)
528+
525529
# Ensure destination directory exists
526530
dest_dir = os.path.dirname(output_file)
527531
if dest_dir and not os.path.exists(dest_dir):

stackql_deploy/cmd/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ def run(self, dry_run, show_queries, on_failure, output_file=None):
409409
elif type == 'query':
410410
self.logger.info(f"✅ successfully exported variables for query in {resource['name']}")
411411

412-
# Process stack-level exports after all resources are deployed
413-
self.process_stack_exports(dry_run, output_file)
414-
415412
elapsed_time = datetime.datetime.now() - start_time
416413
self.logger.info(f"deployment completed in {elapsed_time}")
414+
415+
# Process stack-level exports after all resources are deployed
416+
self.process_stack_exports(dry_run, output_file, elapsed_time)

stackql_deploy/cmd/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,4 @@ def run(self, dry_run, show_queries, on_failure, output_file=None):
149149

150150
# Process stack-level exports if specified
151151
if output_file:
152-
self.process_stack_exports(dry_run, output_file)
152+
self.process_stack_exports(dry_run, output_file, elapsed_time)

website/docs/manifest_fields/exports.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ exports:
1515
```
1616
1717
**Notes**:
18-
- `stack_name` and `stack_env` are automatically included in exports and do not need to be listed
18+
- `stack_name`, `stack_env`, and `elapsed_time` are automatically included in exports and do not need to be listed
19+
- Export order: automatic exports (`stack_name`, `stack_env`) first, then user-defined exports, then timing (`elapsed_time`) last
20+
- `elapsed_time` is formatted as a string showing the total deployment duration (e.g., "0:01:23.456789")
1921
- Variables are exported exactly as they exist in the deployment context
2022
- Complex objects and arrays are preserved as JSON structures
2123
- If a listed variable doesn't exist in the context, deployment will fail

0 commit comments

Comments
 (0)