Skip to content

Commit

Permalink
Remove bumpversion and use bump-my-version (#271)
Browse files Browse the repository at this point in the history
address comments and test

Fix lint and add mock for credentials test

Fix quotes

Change to print so user always sees message

Add more print statements so the user is aware the instance is created
  • Loading branch information
R-Palazzo authored and lajohn4747 committed Mar 8, 2024
1 parent 3e126d7 commit aa0a607
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions sdgym/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ def _get_empty_dataframe(compute_quality_score, sdmetrics):
return scores


<<<<<<< HEAD
def _directory_exists(bucket_name, s3_file_path):
# Find the last occurrence of '/' in the file path
last_slash_index = s3_file_path.rfind('/')
Expand Down Expand Up @@ -484,6 +485,19 @@ def _parse_s3_path(s3_path):

def _create_sdgym_script(params, output_filepath):
bucket_name, key_name = _parse_s3_path(output_filepath)
=======
def _create_sdgym_script(params, output_filepath):
first_slash_index = output_filepath.find('/') # Find the index of the first slash
bucket_name = ''
key_name = ''
if first_slash_index != -1: # Check if a slash is found
bucket_name = output_filepath[:first_slash_index] # Extract directory part
key_name = output_filepath[first_slash_index + 1:] # Extract filename part
else:
raise ValueError("""Invalid output_filepath.
The path should be structured as: <s3_bucket_name>/<path_to_file>
Please make sure the path exists and permissions are given.""")
>>>>>>> 8d58603 (Remove bumpversion and use bump-my-version (#271))
session = boto3.session.Session()
credentials = session.get_credentials()
synthesizer_string = 'synthesizers=['
Expand Down Expand Up @@ -532,7 +546,11 @@ def _create_instance_on_ec2(script_content):
ec2_client = boto3.client('ec2')
session = boto3.session.Session()
credentials = session.get_credentials()
<<<<<<< HEAD
print(f'This instance is being created in region: {session.region_name}') # noqa
=======
print(f'This instance is being created in region: {session.region_name}') # noqa
>>>>>>> 8d58603 (Remove bumpversion and use bump-my-version (#271))

# User data script to install the library
user_data_script = f"""#!/bin/bash
Expand Down Expand Up @@ -588,7 +606,11 @@ def _create_instance_on_ec2(script_content):
instance_id = response['Instances'][0]['InstanceId']
waiter = ec2_client.get_waiter('instance_status_ok')
waiter.wait(InstanceIds=[instance_id])
<<<<<<< HEAD
print(f'Job kicked off for SDGym on {instance_id}') # noqa
=======
print(f'Job kicked off for SDGym on {instance_id}') # noqa
>>>>>>> 8d58603 (Remove bumpversion and use bump-my-version (#271))


def benchmark_single_table(synthesizers=DEFAULT_SYNTHESIZERS, custom_synthesizers=None,
Expand Down Expand Up @@ -656,7 +678,11 @@ def benchmark_single_table(synthesizers=DEFAULT_SYNTHESIZERS, custom_synthesizer
A table containing one row per synthesizer + dataset + metric.
"""
if run_on_ec2:
<<<<<<< HEAD
print("This will create an instance for the current AWS user's account.") # noqa
=======
print("This will create an instance for the current AWS user's account.") # noqa
>>>>>>> 8d58603 (Remove bumpversion and use bump-my-version (#271))
if output_filepath is not None:
script_content = _create_sdgym_script(dict(locals()), output_filepath)
_create_instance_on_ec2(script_content)
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import pytest

from sdgym import benchmark_single_table
<<<<<<< HEAD
from sdgym.benchmark import _check_write_permissions, _create_sdgym_script, _directory_exists
=======
from sdgym.benchmark import _create_sdgym_script
>>>>>>> 8d58603 (Remove bumpversion and use bump-my-version (#271))
from sdgym.synthesizers import CTGANSynthesizer, GaussianCopulaSynthesizer


Expand Down

0 comments on commit aa0a607

Please sign in to comment.