Skip to content

Commit

Permalink
Merge pull request #379 from grycap/dev_micafer
Browse files Browse the repository at this point in the history
Fix style issues
  • Loading branch information
micafer committed Feb 16, 2022
2 parents fdf560d + fe76a5e commit 259c54f
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ A. Pérez, G. Moltó, M. Caballer, and A. Calatrava, “Serverless computing for
<a id="acknowledgements"></a>
## Acknowledgements

* [udocker](https://github.com/indigo-dc/udocker)
* [udocker](https://github.com/indigo-dc/udocker)
2 changes: 1 addition & 1 deletion scar/cmdtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def init(self):
def invoke(self):
pass

@abc.abstractmethod
@abc.abstractmethod
def run(self):
pass

Expand Down
3 changes: 1 addition & 2 deletions scar/http/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import requests

def call_http_endpoint(url, **kwargs):
"""
Does a 'GET' or 'PUT' request if the parameter 'data' exists or not respectively
"""Does a 'GET' or 'PUT' request if the parameter 'data' exists or not respectively
:param url: URL for the request.
:param data: (optional) Dictionary (will be form-encoded), bytes, or file-like object to send in the body of the request.
Expand Down
2 changes: 1 addition & 1 deletion scar/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def init_execution_trace():
def end_execution_trace():
logging.info('SCAR execution finished')
logging.info('----------------------------------------------------')

def end_execution_trace_with_errors():
logging.info('SCAR execution finished with errors')
logging.info('----------------------------------------------------')
Expand Down
2 changes: 1 addition & 1 deletion scar/parser/cfgfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
'integrationHttpMethod' : "POST",
'uri' : "arn:aws:apigateway:{api_region}:lambda:path/2015-03-31/functions/arn:aws:lambda:{lambda_region}:{account_id}:function:{function_name}/invocations",
'requestParameters' : {"integration.request.header.X-Amz-Invocation-Type":
"method.request.header.X-Amz-Invocation-Type"}
"method.request.header.X-Amz-Invocation-Type"}
},
'path_part': "{proxy+}",
'stage_name': "scar",
Expand Down
2 changes: 1 addition & 1 deletion scar/parser/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _get_lambda_environment_variables(lambda_args: Dict) -> None:
lambda_env_vars['container']['environment']['Variables'][f'{key_val[0]}'] = key_val[1]
del(lambda_args['environment_variables'])
if "extra_payload" in lambda_args:
lambda_env_vars['container']['extra_payload'] = f"/var/task"
lambda_env_vars['container']['extra_payload'] = "/var/task"
if "init_script" in lambda_args:
lambda_env_vars['container']['init_script'] = f"/var/task/{FileUtils.get_file_name(lambda_args['init_script'])}"
if "image" in lambda_args:
Expand Down
2 changes: 1 addition & 1 deletion scar/providers/aws/cloudwatchlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _get_lambda_logs(self):
except ClientError as cerr:
logger.warning("Error getting the function logs: %s" % cerr)
return function_logs

def _get_batch_job_log(self, jobs_info: List) -> str:
"""Returns Batch logs for an specific job."""
batch_logs = ""
Expand Down
4 changes: 2 additions & 2 deletions scar/providers/aws/containerimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def _create_dockerfile_ecr_image(lambda_info: Dict) -> str:
dockerfile += 'ENV PYTHONIOENCODING="utf8"\n'

# Add user environment variables
vars = lambda_info.get('container').get('environment').get('Variables', {})
for key, value in vars.items():
variables = lambda_info.get('container').get('environment').get('Variables', {})
for key, value in variables.items():
dockerfile += 'ENV %s="%s"\n' % (key, value)

dockerfile += 'CMD [ "supervisor" ]\n'
Expand Down
6 changes: 3 additions & 3 deletions scar/providers/oscar/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# 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.
"""Module with the class implementing the low-level functions to
"""Module with the class implementing the low-level functions to
communicate with an OSCAR cluster."""

from typing import Dict, List
Expand All @@ -35,7 +35,7 @@ def _get_error_msg(res: requests.Response) -> str:
error_msg = 'The Service doesn\'t exist'
elif res.status_code == 500:
error_msg = 'Internal Server Error'
return error_msg
return error_msg


class OSCARClient():
Expand All @@ -47,7 +47,7 @@ def __init__(self, credentials_info: Dict, cluster_id: str):
self.auth_user = credentials_info['auth_user']
self.auth_password = credentials_info['auth_password']
self.ssl_verify = credentials_info['ssl_verify']

def create_service(self, **kwargs: Dict) -> Dict:
"""Creates a new OSCAR service."""
logger.debug('Creating OSCAR service.')
Expand Down
1 change: 0 additions & 1 deletion scar/providers/oscar/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from tabulate import tabulate
from scar.providers.aws.response import OutputType
import scar.logger as logger
from scar.utils import StrUtils


def parse_ls_response(oscar_resources: List, endpoint: str, cluster_id: str, output_type: int) -> None:
Expand Down
7 changes: 4 additions & 3 deletions test/functional/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class AwsTest(unittest.TestCase):
def tearDown(self):
self.execute_command(self.get_cmd(["rm","-a"]))

def execute_command(self, cmd):
@staticmethod
def execute_command(cmd):
return subprocess.check_output(cmd).decode("utf-8")

def get_cmd(self, extra_args):
Expand All @@ -50,7 +51,7 @@ def test_empty_ls_table(self):

cmd = self.get_cmd(["ls", "-v"])
cmd_out = self.execute_command(cmd)
self.assertEqual(json.loads(cmd_out), {"Functions": []})
self.assertEqual(json.loads(cmd_out), {"Functions": []})

def test_init_ls_run_rm_function(self):
func_name = "scar-test-init-ls-run-rm"
Expand All @@ -60,7 +61,7 @@ def test_init_ls_run_rm_function(self):
cmd_out = self.execute_command(cmd)
self.assertTrue("NAME MEMORY TIME IMAGE_ID API_URL" in cmd_out)
self.assertTrue("------------------------ -------- ------ ---------- ---------" in cmd_out)
self.assertTrue("{0} 512 300 centos:7 -".format(func_name) in cmd_out)
self.assertTrue("{0} 512 300 centos:7 -".format(func_name) in cmd_out)

cmd = self.get_cmd(["run", "-n", func_name])
cmd_out = self.execute_command(cmd)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/parser/fdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def testFDL(self):
if function['name'] == 'function1':
self.assertEqual(len(function['env_vars'].items()), 8)
elif function['name'] == 'function2':
self.assertEqual(len(function['env_vars'].items()), 5)
self.assertEqual(len(function['env_vars'].items()), 5)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aws/test_ecr.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _init_mocks(call_list):
session = MagicMock(['client'])
client = MagicMock(call_list)
session.client.return_value = client
return session
return session

@patch('boto3.Session')
def test_get_authorization_token(self, boto_session):
Expand Down
5 changes: 3 additions & 2 deletions test/unit/aws/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ def test_init(self):
s3 = S3({})
self.assertEqual(type(s3.client.client).__name__, "S3")

def _init_mocks(self, call_list):
@staticmethod
def _init_mocks(call_list):
session = MagicMock(['client'])
client = MagicMock(call_list)
session.client.return_value = client
return session
return session

@patch('boto3.Session')
def test_create_bucket(self, boto_session):
Expand Down

0 comments on commit 259c54f

Please sign in to comment.