feat: ability to set configurations in python model#663
feat: ability to set configurations in python model#663akmalsoliev wants to merge 5 commits intoaws-samples:mainfrom
Conversation
|
BUG: Doesn't properly close the connection once the process is complete. P.S.: If anyone feels like helping out with this would be appreciated. |
|
Just realized that it is not a PR specific issue, rather than a face that session_id is being dropped during the process, will investigate further. |
|
After doing some digging found out that you're testing installation of |
|
Thank you for the contribution. Would you help clarifying/fix following items:
|
|
Hey @yotahk,
I'm unsure why, but when attempting to install via import validoopsie as vd
vd
Agree, this was a work around as Would like to get your feedback prior to proceeding with changes, opened this PR and modifications as a form of "working alternative draft". |
|
@akmalsoliev I can take a look on my side too, would you be able to share some code to reproduce the issue? |
0213f16 to
6bdf61c
Compare
Hey Yota, Also noticed that you were indeed checking that additional package is present in |
fda8442 to
c010f1b
Compare
|
Hey @yotahk, def _string_to_dict(self, value_to_convert):
value_in_dictionary = {}
- for i in value_to_convert.split(","):
- value_in_dictionary[i.split("=")[0].strip('\'').replace("\"", "")] = i.split("=")[1].strip('"\'')
+ for i in value_to_convert.split("--"):
+ i = i.strip()
+ if i == "":
+ continue
+ i = f"--{i}"
+ if i[-1] == ',':
+ i=i.rstrip(",")
+ value_in_dictionary[i.split(":")[0].strip('\'').replace("\"", "")] = i.split(":")[1].strip('"\'')
return value_in_dictionarytests/unit/gluedbapi/test_connection.py call_kwargs = mock_client.create_session.call_args[1]
default_args = call_kwargs["DefaultArguments"]
assert "--additional-python-modules" not in default_args
+
+ @mock.patch("dbt.adapters.glue.gluedbapi.connection.get_session_waiter")
+ @mock.patch("dbt.adapters.glue.gluedbapi.connection.boto3")
+ def test_create_session_with_default_arguments_dict_and_list_values(
+ self, mock_boto3, mock_waiter
+ ) -> None:
+ """Test that default_arguments as a dict with list values joins them into comma-separated strings."""
+ mock_waiter.return_value = mock.Mock()
+ mock_session = mock_boto3.session.Session.return_value
+ mock_client = mock_session.client.return_value
+
+ credentials = GlueCredentials(
+ role_arn="arn:aws:iam::123456789012:role/GlueRole",
+ region="us-east-1",
+ workers=2,
+ worker_type="G.1X",
+ schema="test_schema",
+ default_arguments="--enable-metrics: true, --additional-python-modules:numpy,pandas,scikit-learn",
+ )
+
+ connection = GlueConnection(credentials)
+ connection._create_session("test-session-id")
+
+ mock_client.create_session.assert_called_once()
+ call_kwargs = mock_client.create_session.call_args[1]
+ default_args = call_kwargs["DefaultArguments"]
+
+ assert default_args["--enable-metrics"] == "true"
+ assert "--additional-python-modules" in default_args
+ assert (
+ default_args["--additional-python-modules"] == "numpy,pandas,scikit-learn"
+ ) |
|
Hey @yotahk, modified couple of things, now an operator can set a full list of configurations in python model through I think this is much nicer approach. |
resolves #
Description
dbt.configinside of a python modelChecklist
CHANGELOG.mdand added information about my change to the "dbt-glue next" section.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.