Skip to content

Commit

Permalink
Merge pull request #25 from runprism/dev
Browse files Browse the repository at this point in the history
v0.2.0
  • Loading branch information
mtrivedi50 committed Jul 22, 2023
2 parents 7f616eb + 87a8e1d commit d578c68
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 192 deletions.
492 changes: 309 additions & 183 deletions prism/agents/ec2.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion prism/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#############

# Version number
VERSION = '0.2.0rc2'
VERSION = '0.2.0'

# Root directory of project
ROOT_DIR = str(Path(os.path.dirname(__file__)).parent)
Expand Down
15 changes: 13 additions & 2 deletions prism/mixins/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,19 @@ def create_key_pair(self,
)
if not Path(directory).is_dir():
Path(directory).mkdir(parents=True)
with open(Path(directory / f"{key_name}.pem"), 'w') as f:
f.write(response["KeyMaterial"])

# Write the key to a local file
try:
with open(Path(directory / f"{key_name}.pem"), 'w') as f:
f.write(response["KeyMaterial"])

# If the path already exists and cannot be edited, then raise the exception. But
# first, delete the newly created key pair.
except Exception as e:
ec2_client.delete_key_pair(
KeyName=key_name
)
raise e

# Change the permissions
os.chmod(Path(directory / f"{key_name}.pem"), stat.S_IREAD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ def extract(tasks, hooks):
api_url = "https://restcountries.com/v3.1/all"
resp = requests.get(api_url, verify=False)
data = json.loads(resp.text)
data = sorted(data, key=lambda x: x["name"]["common"])
return data
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def transform(tasks, hooks):
independent_countries.append(c)
except KeyError:
continue
return independent_countries
return sorted(independent_countries, key=lambda x: x["name"]["common"])


@task(
Expand Down
8 changes: 4 additions & 4 deletions prism/tests/integration/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,8 +1339,8 @@ def test_project_local_tasks(self):
all_countries = json.loads(f.read())
with open(Path(wkdir / 'output' / 'independent_countries.json'), 'r') as f:
independent_countries = json.loads(f.read())
self.assertEqual(all_countries[-1]["name"]["common"], "Guinea-Bissau")
self.assertEqual(independent_countries[0]["name"]["common"], "Jordan")
self.assertEqual(all_countries[-1]["name"]["common"], "Åland Islands")
self.assertEqual(independent_countries[0]["name"]["common"], "Afghanistan")

# Remove the .compiled directory, if it exists
self._remove_compiled_dir(wkdir)
Expand Down Expand Up @@ -1398,7 +1398,7 @@ def test_project_local_tasks_specific_module(self):
)
with open(Path(wkdir / 'output' / 'all_countries.json'), 'r') as f:
all_countries = json.loads(f.read())
self.assertEqual(all_countries[-1]["name"]["common"], "Guinea-Bissau")
self.assertEqual(all_countries[-1]["name"]["common"], "Åland Islands")

# ------------------------------------------
# Now, execute transform_load
Expand Down Expand Up @@ -1427,7 +1427,7 @@ def test_project_local_tasks_specific_module(self):
self.assertTrue(Path(wkdir / 'output' / 'independent_countries.json').is_file())
with open(Path(wkdir / 'output' / 'independent_countries.json'), 'r') as f:
independent_countries = json.loads(f.read())
self.assertEqual(independent_countries[0]["name"]["common"], "Jordan")
self.assertEqual(independent_countries[0]["name"]["common"], "Afghanistan")

# Remove the .compiled directory, if it exists
self._remove_compiled_dir(wkdir)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = prism-ds
description = The easiest way to create data pipelines in Python.
long_description_content_type = text/markdown
long_description = file: README.md
version = 0.2.0rc2
version = 0.2.0
author = prism founders
author_email = hello@runprism.com
license = Apache-2.0
Expand Down

0 comments on commit d578c68

Please sign in to comment.