Skip to content
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

Python - Formatting: Runs black formatter on all files #6596

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tools/readmes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@
"sdk_api_ref": 'https://awscli.amazonaws.com/v2/documentation/api/latest/reference/{{service["name"]}}/index.html',
}
},
}
}
3 changes: 3 additions & 0 deletions .tools/readmes/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def _transform_hello(self, pre_hello):
"file": self.scanner.snippet(
pre, self.sdk_ver, self.lang_config["service_folder"], api
),
"run_file": self.scanner.snippet(
pre, self.sdk_ver, self.lang_config["service_folder"], ""
),
"api": api,
}
post_hello.append(action)
Expand Down
19 changes: 9 additions & 10 deletions .tools/readmes/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ def hello(self):
self._load_examples()
hello = {}
for example_name, example in self.example_meta.items():
if (
example.get("category", "") == config.categories["hello"]
and self._contains_language_version(example)
):
if example.get("category", "") == config.categories[
"hello"
] and self._contains_language_version(example):
hello[example_name] = example
return hello

Expand All @@ -108,10 +107,9 @@ def scenarios(self):
self._load_examples()
scenarios = {}
for example_name, example in self.example_meta.items():
if (
example.get("category", "") == config.categories["scenarios"]
and self._contains_language_version(example)
):
if example.get("category", "") == config.categories[
"scenarios"
] and self._contains_language_version(example):
scenarios[example_name] = example
return scenarios

Expand All @@ -120,8 +118,9 @@ def custom_categories(self):
custom_cats = {}
for example_name, example in self.example_meta.items():
if (
example.get("category", "") and
example.get("category", "") not in {config.categories["scenarios"], config.categories["hello"]}
example.get("category", "")
and example.get("category", "")
not in {config.categories["scenarios"], config.categories["hello"]}
and self._contains_language_version(example)
):
custom_cats[example_name] = example
Expand Down
16 changes: 13 additions & 3 deletions python/example_code/aurora/scenario_get_started_aurora.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ def create_cluster(self, cluster_name, db_engine, db_name, parameter_group):
engine_versions = self.aurora_wrapper.get_engine_versions(
db_engine, parameter_group["DBParameterGroupFamily"]
)
engine_choices = [ver["EngineVersionDescription"] for ver in engine_versions]
engine_choices = [
ver["EngineVersionDescription"] for ver in engine_versions
]
print("The available engines for your parameter group are:")
engine_index = q.choose("Which engine do you want to use? ", engine_choices)
print(
Expand Down Expand Up @@ -173,15 +175,23 @@ def create_instance(self, cluster):
inst_opts = self.aurora_wrapper.get_orderable_instances(
cluster["Engine"], cluster["EngineVersion"]
)
inst_choices = list({opt["DBInstanceClass"] + ", storage type: " + opt["StorageType"] for opt in inst_opts})
inst_choices = list(
{
opt["DBInstanceClass"] + ", storage type: " + opt["StorageType"]
for opt in inst_opts
}
)
inst_index = q.choose(
"Which DB instance class do you want to use? ", inst_choices
)
print(
f"Creating a database instance. This typically takes several minutes."
)
db_inst = self.aurora_wrapper.create_instance_in_cluster(
cluster_name, cluster_name, cluster["Engine"], inst_opts[inst_index]["DBInstanceClass"]
cluster_name,
cluster_name,
cluster["Engine"],
inst_opts[inst_index]["DBInstanceClass"],
)
while db_inst.get("DBInstanceStatus") != "available":
wait(30)
Expand Down
2 changes: 1 addition & 1 deletion python/example_code/auto-scaling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ functions within the same service.
This example shows you how to get started using Auto Scaling.

```
python
python hello.py
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ def invoke_agent(self, agent_id, agent_alias_id, session_id, prompt):

# snippet-end:[python.example_code.bedrock-agent-runtime.InvokeAgent]


# snippet-end:[python.example_code.bedrock-agent-runtime.BedrockAgentsRuntimeWrapper.class]
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _send_conversation_to_bedrock(self, conversation):
)

def _process_model_response(
self, model_response, conversation, max_recursion=MAX_RECURSIONS
self, model_response, conversation, max_recursion=MAX_RECURSIONS
):
"""
Processes the response received via Amazon Bedrock and performs the necessary actions
Expand Down Expand Up @@ -153,7 +153,7 @@ def _process_model_response(
return

def _handle_tool_use(
self, model_response, conversation, max_recursion=MAX_RECURSIONS
self, model_response, conversation, max_recursion=MAX_RECURSIONS
):
"""
Handles the tool use case by invoking the specified tool and sending the tool's response back to Bedrock.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ def __init__(self, region="us-east-1", config=None):

self._kms_key_arn = None
self._iam_client = self._session.client("iam")
self._permission_boundary_policy_name = "AmazonDataZoneBedrockPermissionsBoundary"
self._permission_boundary_policy_name = (
"AmazonDataZoneBedrockPermissionsBoundary"
)

def run(self):
logger.info("=" * 80)
Expand Down Expand Up @@ -334,16 +336,20 @@ def _create_permission_boundary(self):
logger.info("Step 3: Create Permission Boundary.")
logger.info("-" * 80)

logger.info(f"Creating permission boundary: '{self._permission_boundary_policy_name}'...")
logger.info(
f"Creating permission boundary: '{self._permission_boundary_policy_name}'..."
)

try:
self._iam_client.create_policy(
PolicyName=self._permission_boundary_policy_name,
PolicyDocument=self._get_permission_boundary()
PolicyDocument=self._get_permission_boundary(),
)
logger.info(f"Permission boundary policy created.")
except self._iam_client.exceptions.EntityAlreadyExistsException:
logger.warning(f"Policy with name '{self._permission_boundary_policy_name}' already exists.")
logger.warning(
f"Policy with name '{self._permission_boundary_policy_name}' already exists."
)

def _create_kms_key(self):
logger.info("=" * 80)
Expand Down
2 changes: 1 addition & 1 deletion python/example_code/ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ functions within the same service.
This example shows you how to get started using Amazon EC2.

```
python
python hello.py
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/elastic-load-balancing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ functions within the same service.
This example shows you how to get started using Elastic Load Balancing.

```
python
python hello.py
```


Expand Down
17 changes: 14 additions & 3 deletions python/example_code/emr/test/test_install_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,22 @@ def test_install_libraries_on_core_nodes(
runner.add(emr_stubber.stub_list_instances, cluster_id, ["CORE"], instance_ids)
for command in commands:
runner.add(
ssm_stubber.stub_send_command, instance_ids, commands=[command], command_id=command_id
ssm_stubber.stub_send_command,
instance_ids,
commands=[command],
command_id=command_id,
)
runner.add(
ssm_stubber.stub_list_commands,
command_id=command_id,
status_details=status_details,
)
runner.add(ssm_stubber.stub_list_commands, command_id=command_id, status_details=status_details)
if status_details == "InProgress":
runner.add(ssm_stubber.stub_list_commands, command_id=command_id, status_details="Success")
runner.add(
ssm_stubber.stub_list_commands,
command_id=command_id,
status_details="Success",
)
elif status_details == "Failed":
break

Expand Down
2 changes: 1 addition & 1 deletion python/example_code/keyspaces/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ functions within the same service.
This example shows you how to get started using Amazon Keyspaces.

```
python
python hello.py
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/lookoutvision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ python export_datasets.py <project> <destination>
This example shows you how to get started using Lookout for Vision.

```
python
python hello.py
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/medical-imaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ functions within the same service.
This example shows you how to get started using HealthImaging.

```
python
python imaging_set_and_frames_workflow/hello.py
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/redshift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ functions within the same service.
This example shows you how to get started using Amazon Redshift.

```
python
python hello.py
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/s3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Sample applications that work across multiple AWS services.
This example shows you how to get started using Amazon S3.

```
python
python s3_basics/hello.py
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/ssm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ functions within the same service.
This example shows you how to get started using Systems Manager.

```
python
python hello.py
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ functions within the same service.
This example shows you how to get started using Support.

```
python
python hello.py
```


Expand Down
Loading
Loading