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

DTaaS CLI: Base structure and User add/Delete for Compose #578

Conversation

astitva1905
Copy link
Collaborator

@astitva1905 astitva1905 commented Mar 3, 2024

  • Creates new file for additional users ml-workspaces
  • Demos additions of a new user, across all relevant files

Tests:
Screenshot from 2024-03-03 13-13-52
Screenshot from 2024-03-03 13-13-33
Screenshot from 2024-03-03 13-13-28
Screenshot from 2024-03-03 13-13-21

To do:

  • Adding rules to conf file in user add -> (for next PR)

  • Starting new user container from within the user add cli (docker compose -f compose.users.yml up ) -> Done

  • No hardcoding config, instead users.yml.yemplate with recursive replace to fill in params -> Done

  • File path decision for global config file (~/.config/dtaas/config.yml) -> Changed to dtaas.toml (fornow assumed as always exists in DTaaS/cli/); Done.

  • Setting networks across compose files

  • Linting and testing

  • Packaging and publishing cli

docker/README.md Outdated Show resolved Hide resolved
docker/README.md Outdated Show resolved Hide resolved
docker/README.md Outdated Show resolved Hide resolved
cli/add_users.py Outdated Show resolved Hide resolved
cli/add_users.py Outdated Show resolved Hide resolved
cli/add_users.py Outdated Show resolved Hide resolved
cli/add_users.py Outdated Show resolved Hide resolved
docker/.env Outdated Show resolved Hide resolved
@prasadtalasila
Copy link
Contributor

@astitva1905
Please use click for CLI development.

cli/dtaas_cli/cmd.py Outdated Show resolved Hide resolved
cli/dtaas_cli/pkg/users.py Outdated Show resolved Hide resolved
cli/dtaas_cli/cmd.py Outdated Show resolved Hide resolved
cli/dtaas_cli/pkg/users.py Outdated Show resolved Hide resolved
cli/dtaas_cli/pkg/users.py Outdated Show resolved Hide resolved
@prasadtalasila
Copy link
Contributor

prasadtalasila commented Mar 14, 2024

@astitva1905
There is in-built support for TOML config format in python 3.11 onwards. Let us go with TOML config format (instead of YAML format) for DTaaS CLI. The suggested config is in wiki. Only the following part needs implementation in this PR.

# This is the config for DTaaS CLI

name = "Digital Twin as a Service (DTaaS)"
version = "0.1"
owner = "The INTO-CPS-Association"
git-repo = "https://github.com/into-cps-association/DTaaS.git"

[common]
# absolute path to the DTaaS application directory
path = "/home/dtaas/app"

[users]
# matching user info must present in this config file
add = ["username1","username2"] 
remove = ["username3"]

[users.username1]
email = "[email protected]"

[users.username2]
email = "[email protected]"

[users.username3]
email = "[email protected]"

[client.web]
config = "/home/dtaas/app/config/client/env.local.js"

Please name this file as dtaas.toml. We can postpone the default location of this file from this PR and always assume that dtaas.toml exists in the execution directory of dtaas CLI. If the file does not exist the CLI can create the same.

The format of the config subcommands are:

# inspiration "git config -h"
dtaas config [OPTIONS]
    -l --list     show TOML config file
    -g --get path    get the value of common.path variable
    -s --set path     set the value of common.path variable
    -u --unset path     delete the common.path variable from dtaas.toml file

Copy link
Contributor

@prasadtalasila prasadtalasila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the comments.

cli/dtaas_cli/cmd.py Outdated Show resolved Hide resolved
cli/dtaas_cli/cmd.py Outdated Show resolved Hide resolved
cli/dtaas_cli/pkg/dtaas.py Outdated Show resolved Hide resolved
cli/dtaas_cli/pkg/dtaas.py Outdated Show resolved Hide resolved
cli/dtaas_cli/pkg/helper.py Outdated Show resolved Hide resolved
cli/setup.py Outdated Show resolved Hide resolved
docker/.env Outdated Show resolved Hide resolved
docker/conf.local Outdated Show resolved Hide resolved
cli/dtaas_cli/pkg/dtaas.py Outdated Show resolved Hide resolved
docker/compose.users.yml Outdated Show resolved Hide resolved
@prasadtalasila
Copy link
Contributor

The additional stack to be put in:

  • poetry project structure
  • pytest for tests
  • pylint for linting
  • pyright for type checking

Additional TODO: github workflow file to perform all the poetry steps including publish --dry-run step.

@prasadtalasila
Copy link
Contributor

A suggestion to reduce the scope of this PR: Assume the correct formatting of dtaas.toml and skip the implementation of dtaas config... command.

@codecov-commenter
Copy link

Codecov Report

Merging #578 (edaea7f) into feature/distributed-demo (bf079f0) will increase coverage by 29.94%.
Report is 2 commits behind head on feature/distributed-demo.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                      Coverage Diff                      @@
##           feature/distributed-demo     #578       +/-   ##
=============================================================
+ Coverage                     63.38%   93.33%   +29.94%     
=============================================================
  Files                            31        5       -26     
  Lines                           396       45      -351     
  Branches                         26        3       -23     
=============================================================
- Hits                            251       42      -209     
+ Misses                          130        0      -130     
+ Partials                         15        3       -12     
Files Coverage Δ
servers/execution/runner/src/app.controller.ts 100.00% <ø> (ø)
...rvers/execution/runner/src/config/configuration.ts 100.00% <100.00%> (ø)
servers/execution/runner/src/execaCMDRunner.ts 86.66% <ø> (ø)
...s/execution/runner/src/lifecycleManager.service.ts 90.90% <ø> (ø)
servers/execution/runner/src/queue.service.ts 100.00% <ø> (ø)

... and 31 files with indirect coverage changes

Components Coverage Δ
Website ∅ <ø> (∅)
Lib Microservice ∅ <ø> (∅)

@prasadtalasila
Copy link
Contributor

Let the forward-auth config update step (for conf.server and conf.local) be manual.
Use https://pypi.org/project/tomlkit/ for toml file parsing.

cli/src/pkg/users.py Outdated Show resolved Hide resolved
cli/src/pkg/users.py Outdated Show resolved Hide resolved
cli/src/pkg/dtaas.py Outdated Show resolved Hide resolved
cli/src/pkg/users.py Outdated Show resolved Hide resolved
cli/src/pkg/users.py Outdated Show resolved Hide resolved
Copy link
Contributor

@prasadtalasila prasadtalasila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to check the working of the code. Please do add the developer (poetry...) commands to the README

cli/dtaas.toml Outdated

[common]
# absolute path to the DTaaS application directory
server-dns = "domain.com"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foo.com

cli/dtaas.toml Outdated
[common]
# absolute path to the DTaaS application directory
server-dns = "domain.com"
path = "/home/astitva/Desktop/yamlstuff"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/home/dtaas/DTaaS

cli/dtaas.toml Outdated

[users]
# matching user info must present in this config file
add = ["astitvasehgal05","astitvasehgal19", "prasad"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user1,user2,user3


configObj = dtaasPkg.Config()

err = userPkg.deleteUser(configObj)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use try...catch structure

class Config:
def __init__(self):
config, err = utils.importToml('dtaas.toml')
if err!=None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is try....catch iseful here?

import subprocess
from . import utils

def __getComposeConfig(username, server, DTaaSDirPath):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice notation for internal functions.

@astitva1905 astitva1905 changed the title New User ML Workspace Addition to docker deploy DTaaS CLI: Base structure and User add/Delete for Compose Mar 24, 2024
cmdStr = " ".join(cmd)
subprocess.run(cmdStr, shell=True, check=False)

def stopUserContainers(users):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

compose['services'][username] = config
return None

def startUserContainers(users):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

return None, Exception("Config file error: Missing 'common' tag")
return conf['common'], None

def getUsers(self):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.


err = utils.exportYaml(compose, 'compose.users.yml')
if err is not None:
return err
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.


startUserContainers(userList)

return None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.

return err
path, err = configObj.getPath()
if err is not None:
return err
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many returns @prasadtalasila

@prasadtalasila
Copy link
Contributor

Code Climate has analyzed commit 0516468 and detected 24 issues on this pull request.

Here's the issue category breakdown:
Category Count
Complexity 12
Duplication 8
Style 4

View more on Code Climate.

@astitva1905 please resolve these codeclimate issues as well. Thanks.

return None, Exception("Config file error: The server dns isn't set in TOML")
return str(confCommon['server-dns']), None

def getAddUsersList(self):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.


def test_export_yaml():

data = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

assert template==expected

def test_import_yaml_compose():
expected = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.


err = startUserContainers(userList)
if err is not None:
return err
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.

if 'services' not in compose:
return None
if username not in compose['services']:
return None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.

@prasadtalasila
Copy link
Contributor

@astitva1905 some feedback on the CLI after trying in localhost scenario.

  1. Can short option flags be added?
    short flags:
      -h or --help
    
  2. Handle the condition where the DTaaS is not installed
  3. docker/.env has three users while compose has only two users. Can it be deleted?
  4. what happens when new user is added without restarting forward-auth container?
  5. DTaaS CLI does not add user directories in files/. This needs to be done in CLI itself? If the directory does exist, the directory structure needs to be checked.
  6. When a user is added, add array emptied and add user is started again, the console shows the recent user being added.
  7. When delete user is executed, even with empty user array being empty, the user added recently is deleted
  8. When a user from original docker-compose file is attempted to be deleted, the following error comes:
    dtaas admin user delete
    no such service: kelvin
    Error: Error while deleting users: failed to stop containers
    

addUsersList = [ str(username) for username in confUsers['add']]
return addUsersList, None

def getDeleteUsersList(self):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

}
}

expected = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.


err = utils.exportYaml(compose, 'compose.users.yml')
if err is not None:
return err
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.

if err is not None:
return err

return None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.


def test_replace_all():

template = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

return None, Exception(f"Error while getting toml file: {filename}, " + str(err))
return config, None

def replaceAll(obj, mapping):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.

cli/src/pkg/utils.py Show resolved Hide resolved
cli/src/pkg/utils.py Show resolved Hide resolved

obj[key], err = replaceAll(obj[key], mapping)
if err is not None:
return None, err
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.

if err is not None:
return None, err

return obj, None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.

return None, Exception(f"Error while getting toml file: {filename}, " + str(err))
return config, None

def replaceAll(obj, mapping):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.




def checkError(err):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename function "checkError" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.

return None, Exception(f"Error while getting toml file: {filename}, " + str(err))
return config, None

def replaceAll(obj, mapping):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename function "replaceAll" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.

return None, err
return obj, None

return None, Exception("Config substition failed: Object format not valid")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this function.

return

#### user group commands
@user.command()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.


return None, Exception("Config substition failed: Object format not valid")

def replaceString(obj, mapping):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename function "replaceString" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.

cli/src/pkg/utils.py Show resolved Hide resolved

return None

def deleteUser(configObj):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename function "deleteUser" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.

raise click.ClickException("Error while adding users: " + str(err))
click.echo("Users added successfully")

@user.command()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

return self.data,None
return None, Exception("Config not initialised")

def getCommon(self):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

return Exception("failed to stop containers")
return None

def addUsers(configObj):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename function "addUsers" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.

import shutil
from src.pkg import utils

def getComposeConfig(username, server, path):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename function "getComposeConfig" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.

cli/src/cmd.py Outdated
""" This file defines all cli entrypoints for dtaas"""

import click
#from . import service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this commented out code.


return config, None

def createUserFiles(users, filePath):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename function "createUserFiles" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.

return Exception("failed to start containers")
return None

def stopUserContainers(users):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename function "stopUserContainers" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.


return None

def deleteUser(configObj):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function deleteUser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

return None, Exception(f"Error while getting toml file: {filename}, " + str(err))
return config, None

def replaceAll(obj, mapping):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function replaceAll has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.

import subprocess


def test_add_user_cli():
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

result =subprocess.run(["dtaas admin user add"], shell=True)
assert result.returncode == 0

def test_delete_user_cli():
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

cli/README.md Outdated
```
### Additional Points to Remember

- The base DTaaS system should be up and running before adding/deleting users with the CLI
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

cli/README.md Outdated
- The base DTaaS system should be up and running before adding/deleting users with the CLI

- The _user add_ CLI will add and start a container for a new user.
It can also start a container for an existing user if that container was somehow stopped.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

cli/README.md Outdated

- The _user add_ CLI will add and start a container for a new user.
It can also start a container for an existing user if that container was somehow stopped.
It shows a _Running_ status for existing user containers that are already up and running,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

cli/README.md Outdated
It shows a _Running_ status for existing user containers that are already up and running,
it doesn't restart them.

- Configure the _server-dns_ in the _dtaas.toml_ file with the domain name of your server.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

cli/README.md Outdated
- Configure the _server-dns_ in the _dtaas.toml_ file with the domain name of your server.
If you want to bring up the server locally, please set this to _"localhost"_.

- _user add_ and _user delete_ CLIs return an error if the _add_ and _delete_ lists in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

cli/README.md Outdated
- _user add_ and _user delete_ CLIs return an error if the _add_ and _delete_ lists in
_dtaas.toml_ are empty, respectively.

- Currently the _email_ fields for each user in dtaas.toml are not in use, and are not necessary
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

cli/README.md Outdated
_dtaas.toml_ are empty, respectively.

- Currently the _email_ fields for each user in dtaas.toml are not in use, and are not necessary
to fill in. These emails must be configured manually for each user in the docker/conf.local or
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

cli/README.md Outdated

- Currently the _email_ fields for each user in dtaas.toml are not in use, and are not necessary
to fill in. These emails must be configured manually for each user in the docker/conf.local or
docker/conf.server files and the _traefik-forward-auth_ container must be restarted as described above.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length


```bash
dtaas admin user delete
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenced code blocks should be surrounded by blank lines

singleton Config class, which is used throughout the CLI. Additionally,
it contains the handling functions for each CLI. These functions perform
the actual operations that the CLI command is responsible for. It also
has helper functions that can be used across the CLI.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces


## Poetry

We use [Poetry Package](https://python-poetry.org/docs/) to manage dependencies and build the CLI. The configuration file for this is
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length


assert filecmp.cmp('tests/compose.users.test.yml', 'tests/compose.users.exp.yml')

def getReplaceAllObject(stringval1, stringval2, stringval3, listval1, listval2, listval3):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function getReplaceAllObject has 6 arguments (exceeds 4 allowed). Consider refactoring.

cli/DEVELOPER.md Outdated
The CLI is published to [PyPI](https://pypi.org/).
Once new changes to the CLI are merged to the DTaaS
repository, the CLI is also published to the official
DTaaS PyPI account.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces

cli/README.md Outdated Show resolved Hide resolved
cli/README.md Outdated Show resolved Hide resolved
cli/README.md Outdated Show resolved Hide resolved
cli/requirements.txt Outdated Show resolved Hide resolved
cli/DEVELOPER.md Outdated Show resolved Hide resolved
cli/pyproject.toml Outdated Show resolved Hide resolved
cli/DEVELOPER.md Outdated Show resolved Hide resolved
cli/DEVELOPER.md Show resolved Hide resolved
cli/DEVELOPER.md Show resolved Hide resolved
[MISCELLANEOUS]

# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME found


# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
XXX,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XXX found

# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
XXX,
TODO
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

cli/DEVELOPER.md Outdated

## Setup


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple consecutive blank lines

cli/README.md Outdated
```toml
[users]
# matching user info must present in this config file
add = ["username1","username2", "username3"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces

def getFromConfig(self, key):
"""Gets the specific key from config"""
conf, err = self.getConfig()
if err is not None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 5 locations. Consider refactoring.

def getStringFromCommon(self, key):
"""Gets the specific string key from config.common"""
confCommon, err = self.getCommon()
if err is not None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 5 locations. Consider refactoring.

def getStringListFromUsers(self, key):
"""Gets the specific key as a list of strings from config.users"""
confUsers, err = self.getUsers()
if err is not None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 5 locations. Consider refactoring.

def replaceList(arr, mapping):
for ind, val in enumerate(arr):
arr[ind], err = replaceAll(val, mapping)
if err is not None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 5 locations. Consider refactoring.

if not isinstance(key,str):
return None, Exception("Config substitution failed: Key is not a string")
dictionary[key], err = replaceAll(dictionary[key], mapping)
if err is not None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 5 locations. Consider refactoring.

Copy link

codeclimate bot commented May 1, 2024

Code Climate has analyzed commit 6d5deb0 and detected 0 issues on this pull request.

View more on Code Climate.

@prasadtalasila prasadtalasila merged commit 210af87 into INTO-CPS-Association:feature/distributed-demo May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants