Skip to content

Commit 38763cd

Browse files
committed
Move boto imports
1 parent 42d9368 commit 38763cd

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/nomad_ml_workflows/actions/export_remote_entries/activities.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from typing import Any
1010
from urllib.parse import urlparse
1111

12-
import boto3
1312
from nomad.actions.manager import action_instance_artifacts_dir
1413
from nomad.files import StagingUploadFiles
1514
from nomad.uploads import get_upload_files
@@ -122,6 +121,8 @@ def _upload_dataset_to_s3(
122121
artifacts_subdirectory: Path,
123122
) -> str:
124123
"""Upload exported dataset files to S3-compatible remote storage."""
124+
import boto3
125+
125126
client_kwargs = _build_boto3_client_kwargs(storage_settings)
126127
s3_client = boto3.client('s3', **client_kwargs)
127128
bucket = storage_settings.bucket
@@ -150,6 +151,8 @@ def _copy_dataset_from_s3_to_upload(
150151
storage_settings: S3StorageSettings,
151152
) -> str:
152153
"""Download an S3 dataset and add it to a NOMAD staging upload."""
154+
import boto3
155+
153156
bucket, key = _parse_s3_uri(data.remote_uri)
154157
client_kwargs = _build_boto3_client_kwargs(storage_settings)
155158
s3_client = boto3.client('s3', **client_kwargs)

tests/actions/export_remote_entries/test_activities.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_read_num_entries_exported(mock_artifacts_dir, tmp_path):
3232

3333

3434
@pytest.mark.asyncio
35-
@patch('nomad_ml_workflows.actions.export_remote_entries.activities.boto3.client')
35+
@patch('boto3.client')
3636
@patch(
3737
'nomad_ml_workflows.actions.export_remote_entries.activities.action_instance_artifacts_dir'
3838
)
@@ -88,7 +88,7 @@ async def test_upload_dataset_to_remote_storage_s3_zipped(
8888

8989

9090
@pytest.mark.asyncio
91-
@patch('nomad_ml_workflows.actions.export_remote_entries.activities.boto3.client')
91+
@patch('boto3.client')
9292
@patch(
9393
'nomad_ml_workflows.actions.export_remote_entries.activities.action_instance_artifacts_dir'
9494
)
@@ -129,7 +129,7 @@ async def test_upload_dataset_to_remote_storage_s3_unzipped(
129129

130130

131131
@pytest.mark.asyncio
132-
@patch('nomad_ml_workflows.actions.export_remote_entries.activities.boto3.client')
132+
@patch('boto3.client')
133133
@patch('nomad_ml_workflows.actions.export_remote_entries.activities.get_upload_files')
134134
async def test_copy_remote_dataset_to_upload_s3_zipped(
135135
mock_get_upload_files, mock_boto_client
@@ -164,7 +164,7 @@ async def test_copy_remote_dataset_to_upload_s3_zipped(
164164

165165

166166
@pytest.mark.asyncio
167-
@patch('nomad_ml_workflows.actions.export_remote_entries.activities.boto3.client')
167+
@patch('boto3.client')
168168
@patch('nomad_ml_workflows.actions.export_remote_entries.activities.get_upload_files')
169169
async def test_copy_remote_dataset_to_upload_s3_directory(
170170
mock_get_upload_files, mock_boto_client

0 commit comments

Comments
 (0)