Skip to content

Commit

Permalink
[Fix] pep
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-sidelnikov committed Jan 22, 2025
1 parent c662595 commit 93e1a5e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
4 changes: 3 additions & 1 deletion examples/function_graph/update_function_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@
},
'timeout': 40
}
metadata = conn.functiongraph.update_function_metadata("func_urn", **metadata_attrs)
metadata = conn.functiongraph.update_function_metadata(
"func_urn", **metadata_attrs
)
24 changes: 12 additions & 12 deletions otcextensions/sdk/function_graph/v2/_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ def update_function_code(self, function, **attrs):
:param function: The URN or instance of the Function to update.
:param attrs: Attributes for updating the function code. These include:
- code_type: Function code type. Options:
* `inline`: Inline code.
* `zip`: ZIP file.
* `obs`: Function code stored in an OBS bucket.
* `jar`: JAR file (mainly for Java functions).
- code_url: If `code_type` is set to `obs`, enter the OBS URL
of the function code package. Leave this parameter blank if
`code_type` is not `obs`.
- code_filename: Name of the function file. This parameter
is mandatory only when `code_type` is set to `jar` or `zip`.
- func_code: Response body of the `FuncCode` struct.
- depend_version_list: Dependency version IDs.
- code_type: Function code type. Options:
* `inline`: Inline code.
* `zip`: ZIP file.
* `obs`: Function code stored in an OBS bucket.
* `jar`: JAR file (mainly for Java functions).
- code_url: If `code_type` is set to `obs`, enter the OBS URL
of the function code package. Leave this parameter blank if
`code_type` is not `obs`.
- code_filename: Name of the function file. This parameter
is mandatory only when `code_type` is set to `jar` or `zip`.
- func_code: Response body of the `FuncCode` struct.
- depend_version_list: Dependency version IDs.
:rtype: :class:`~otcextensions.sdk.function_graph.v2.function.Function`
"""
function = self._get_resource(_function.Function, function)
Expand Down
12 changes: 8 additions & 4 deletions otcextensions/sdk/function_graph/v2/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from openstack import resource, exceptions
from openstack import resource
from openstack import exceptions


class TagSpec(resource.Resource):
Expand Down Expand Up @@ -124,7 +125,8 @@ def _get_function_code(self, session, function):
def _get_function_metadata(self, session, function):
"""Get Function Metadata
"""
url = self.base_path + f'/{function.func_urn.rpartition(":")[0]}/config'
urn = function.func_urn.rpartition(":")[0]
url = self.base_path + f'/{urn}/config'
response = session.get(url)
exceptions.raise_from_response(response)
return self
Expand Down Expand Up @@ -159,7 +161,8 @@ def _delete_resource_tags(self, session, function, tags):
def _update_pin_status(self, session, function):
"""Update Pin Status
"""
url = self.base_path + f'/{function.func_urn.rpartition(":")[0]}/collect/true'
urn = function.func_urn.rpartition(":")[0]
url = self.base_path + f'/{urn}/collect/true'
response = session.put(url)
exceptions.raise_from_response(response)
self._translate_response(response)
Expand All @@ -186,7 +189,8 @@ def _update_function_metadata(self, session, function, **attrs):
def _update_max_instances(self, session, function, number):
"""Update Function Instances Number
"""
url = self.base_path + f'/{function.func_urn.rpartition(":")[0]}/config-max-instance'
urn = function.func_urn.rpartition(":")[0]
url = self.base_path + f'/{urn}/config-max-instance'
response = session.put(url, json={'max_instance_num': number})
exceptions.raise_from_response(response)
self._translate_response(response)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Licensed under the Apache License, Version 2.0 (the 'License'); you may
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
Expand Down Expand Up @@ -68,8 +68,6 @@ def test_resource_tags(self):
]
)
found = self.conn.functiongraph.get_resource_tags(self.function)
self.assertEqual(found.tags[0].key, 'key')
self.assertEqual(found.tags[0].values[0], 'value')
self.assertEqual(len(found.tags), 2)
self.conn.functiongraph.delete_resource_tags(
self.function,
Expand Down

0 comments on commit 93e1a5e

Please sign in to comment.