-
Notifications
You must be signed in to change notification settings - Fork 1
Lal/coal enable runner data prod 15736 #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
37b3774
fb9652f
f1ae53e
51d825c
fc891f7
c70ca4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Copyright (C) - 2023 - 2025 - Cosmo Tech | ||
| # This document and all information contained herein is the exclusive property - | ||
| # including all intellectual property rights pertaining thereto - of Cosmo Tech. | ||
| # Any use, reproduction, translation, broadcasting, transmission, distribution, | ||
| # etc., to any person is prohibited unless it has been previously and | ||
| # specifically authorized by written means by Cosmo Tech. | ||
|
|
||
| from cosmotech.csm_data.utils.click import click | ||
| from cosmotech.csm_data.utils.decorators import translate_help, web_help | ||
|
|
||
|
|
||
| @click.command() | ||
| @web_help("csm-data/store/delete") | ||
| @translate_help("csm_data.commands.store.delete.description") | ||
| def delete(): | ||
| # Import the function at the start of the command | ||
| from cosmotech.coal.store.output import channel_spliter | ||
| from cosmotech.coal.utils.configuration import Configuration | ||
|
|
||
| try: | ||
| _cs = channel_spliter.ChannelSpliter(Configuration()) | ||
| _cs.delete() | ||
| except ValueError as e: | ||
| raise click.Abort() from e |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| description: | | ||
| Delete simulation result from where the output command pushed data. | ||
|
|
||
| This delete is base on the configuration. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| description: | | ||
| Dump simulation from the coal store to the configured output. | ||
|
|
||
| This output is base on the configuration. Default dconfiguration will try to output in postgres. | ||
| This output is base on the configuration. | ||
|
|
||
| parameters: | ||
| filter: names of the tables to output |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,11 @@ def base_azure_storage_config(): | |
| return Configuration( | ||
| { | ||
| "coal": {"store": "$cosmotech.parameters_absolute_path"}, | ||
| "cosmotech": {"dataset_absolute_path": "/path/to/dataset", "parameters_absolute_path": "/path/to/params"}, | ||
| "cosmotech": { | ||
| "runner_id": "r-789", | ||
| "dataset_absolute_path": "/path/to/dataset", | ||
| "parameters_absolute_path": "/path/to/params", | ||
| }, | ||
| "azure": { | ||
| "account_name": "test_account", | ||
| "container_name": "test_container", | ||
|
|
@@ -62,39 +66,54 @@ def test_required_keys(self): | |
| @patch("cosmotech.coal.azure.blob.ClientSecretCredential") | ||
| def test_send_without_filter(self, mock_client_secret, mock_store, mock_dump, base_azure_storage_config): | ||
| """Test sending data without table filter.""" | ||
| # Arrange | ||
| channel = AzureStorageChannel(base_azure_storage_config) | ||
|
|
||
| # Act | ||
| channel.send() | ||
|
|
||
| # Assert | ||
| mock_dump.assert_called_once_with(base_azure_storage_config, selected_tables=None) | ||
| expected_config = base_azure_storage_config | ||
| expected_config.azure.file_prefix = ( | ||
| base_azure_storage_config.cosmotech.runner_id + "/" + base_azure_storage_config.azure.file_prefix | ||
| ) | ||
| mock_dump.assert_called_once_with(expected_config, selected_tables=None) | ||
|
Comment on lines
+76
to
+80
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the channel init function create a new configuration object non prepend is happenning |
||
|
|
||
| @patch("cosmotech.coal.store.output.az_storage_channel.dump_store_to_azure") | ||
| @patch("cosmotech.coal.azure.blob.Store") | ||
| @patch("cosmotech.coal.azure.blob.ClientSecretCredential") | ||
| def test_send_with_filter(self, mock_client_secret, mock_store, mock_dump, base_azure_storage_config): | ||
| """Test sending data with table filter.""" | ||
|
|
||
| # Arrange | ||
| channel = AzureStorageChannel(base_azure_storage_config) | ||
| tables_filter = ["table1", "table2"] | ||
|
|
||
| # Act | ||
| channel.send(filter=tables_filter) | ||
|
|
||
| # Assert | ||
| expected_config = base_azure_storage_config | ||
| expected_config.azure.file_prefix = ( | ||
| base_azure_storage_config.cosmotech.runner_id + "/" + base_azure_storage_config.azure.file_prefix | ||
| ) | ||
| mock_dump.assert_called_once_with( | ||
| base_azure_storage_config, | ||
| expected_config, | ||
| selected_tables=["table1", "table2"], | ||
| ) | ||
|
Comment on lines
+95
to
102
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still, channel init function create a new configuration object no prepend is happening |
||
|
|
||
| def test_delete(self, base_azure_storage_config): | ||
| @patch("cosmotech.coal.store.output.az_storage_channel.delete_azure_blobs") | ||
| @patch("cosmotech.coal.azure.blob.Store") | ||
| @patch("cosmotech.coal.azure.blob.ClientSecretCredential") | ||
| def test_delete(self, mock_client_secret, mock_store, mock_delete, base_azure_storage_config): | ||
| """Test delete method (should do nothing).""" | ||
| channel = AzureStorageChannel(base_azure_storage_config) | ||
|
|
||
| # Act | ||
| result = channel.delete() | ||
| channel.delete() | ||
|
|
||
| # Assert | ||
| # Should not raise any exception and return None | ||
| assert result is None | ||
| expected_config = base_azure_storage_config | ||
| expected_config.azure.file_prefix = ( | ||
| base_azure_storage_config.cosmotech.runner_id + "/" + base_azure_storage_config.azure.file_prefix | ||
| ) | ||
| mock_delete.assert_called_once_with(expected_config) | ||
|
Comment on lines
108
to
+119
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. re non |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change absolutely nothing, parameter value is set/create a function call