Skip to content

Commit

Permalink
Merge pull request #11 from Aquaveo/linting
Browse files Browse the repository at this point in the history
Linting and Cleaning Old Functions
  • Loading branch information
msouff authored Jan 15, 2024
2 parents 02e911f + 0b93c0d commit 455f665
Show file tree
Hide file tree
Showing 21 changed files with 465 additions and 1,779 deletions.
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sphinx_rtd_theme
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def find_resource_files(directory, relative_to=None):
paths = []
for (path, directories, filenames) in os.walk(directory):
for (path, _directories, filenames) in os.walk(directory):
for filename in filenames:
if relative_to is not None:
paths.append(os.path.join(os.path.relpath(path, relative_to), filename))
Expand Down
19 changes: 0 additions & 19 deletions tethysapp/app_store/api.py

This file was deleted.

2 changes: 1 addition & 1 deletion tethysapp/app_store/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tethys_sdk.base import TethysAppBase
from tethys_sdk.app_settings import CustomSetting,JSONCustomSetting,SecretCustomSetting
from tethys_sdk.app_settings import CustomSetting, JSONCustomSetting, SecretCustomSetting
from tethys_sdk.permissions import Permission, PermissionGroup


Expand Down
7 changes: 4 additions & 3 deletions tethysapp/app_store/application_files/setup_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

def find_resource_files(directory, relative_to=None):
paths = []
for (path, directories, filenames) in os.walk(directory):
for (path, _directories, filenames) in os.walk(directory):
for filename in filenames:
if relative_to is not None:
paths.append(os.path.join(os.path.relpath(path, relative_to), filename))
else:
paths.append(os.path.join('..', path, filename))
return paths



def find_resource_files_of_type(resource_type, app_package, app_root):
relative_to = f"{app_root}/{app_package}"
resources = find_resource_files(f"{relative_to}/{resource_type}", relative_to)
Expand All @@ -23,4 +24,4 @@ def find_all_resource_files(app_package, app_root):
resources += find_resource_files_of_type("workspaces", app_package, app_root)
resources += find_resource_files_of_type("scripts", app_package, app_root)

return resources
return resources
43 changes: 20 additions & 23 deletions tethysapp/app_store/begin_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from subprocess import call

from .helpers import check_all_present, get_app_instance_from_path, logger, send_notification
from .resource_helpers import get_resource, get_resource_new
from .resource_helpers import get_resource


def handle_property_not_present(prop):
Expand Down Expand Up @@ -55,7 +55,6 @@ def detect_app_dependencies(app_name, channel_layer, notification_method=send_no
# paths = list(filter(lambda x: app_name in x, store_pkg.__path__))
paths = list(filter(lambda x: app_name in x, tethysapp.__path__))


if len(paths) < 1:
logger.error("Can't find the installed app location.")
return
Expand All @@ -79,7 +78,7 @@ def detect_app_dependencies(app_name, channel_layer, notification_method=send_no
# Checkpoints for the output
str_output = str(output.strip())
logger.info(str_output)
if(check_all_present(str_output, ['PIP Install Complete'])):
if (check_all_present(str_output, ['PIP Install Complete'])):
break

notification_method("PIP install completed", channel_layer)
Expand All @@ -88,14 +87,14 @@ def detect_app_dependencies(app_name, channel_layer, notification_method=send_no

app_instance = get_app_instance_from_path(paths)
custom_settings_json = []
custom_settings = app_instance.custom_settings()

if getattr(app_instance, "custom_settings"):
if custom_settings:
notification_method("Processing App's Custom Settings....", channel_layer)
custom_settings = getattr(app_instance, "custom_settings")
for setting in custom_settings() or []:
setting = {"name": getattr(setting, "name"),
"description": getattr(setting, "description"),
"default": str(getattr(setting, "default")),
for setting in custom_settings:
setting = {"name": setting.name,
"description": setting.description,
"default": str(setting.default),
}
custom_settings_json.append(setting)

Expand All @@ -110,7 +109,7 @@ def detect_app_dependencies(app_name, channel_layer, notification_method=send_no
return


def conda_install(app_metadata, app_channel,app_label,app_version, channel_layer):
def conda_install(app_metadata, app_channel, app_label, app_version, channel_layer):

start_time = time.time()
send_notification("Mamba install may take a couple minutes to complete depending on how complicated the "
Expand All @@ -127,7 +126,7 @@ def conda_install(app_metadata, app_channel,app_label,app_version, channel_layer
app_name = app_metadata['name'] + "=" + app_version

label_channel = f'{app_channel}'

if app_label != 'main':
label_channel = f'{app_channel}/label/{app_label}'

Expand All @@ -145,18 +144,18 @@ def conda_install(app_metadata, app_channel,app_label,app_version, channel_layer
# Checkpoints for the output
str_output = str(output.strip())
logger.info(str_output)
if(check_all_present(str_output, ['Collecting package metadata', 'done'])):
if (check_all_present(str_output, ['Collecting package metadata', 'done'])):
send_notification("Package Metadata Collection: Done", channel_layer)
if(check_all_present(str_output, ['Solving environment', 'done'])):
if (check_all_present(str_output, ['Solving environment', 'done'])):
send_notification("Solving Environment: Done", channel_layer)
if(check_all_present(str_output, ['Verifying transaction', 'done'])):
if (check_all_present(str_output, ['Verifying transaction', 'done'])):
send_notification("Verifying Transaction: Done", channel_layer)
if(check_all_present(str_output, ['All requested packages already installed.'])):
if (check_all_present(str_output, ['All requested packages already installed.'])):
send_notification("Application package is already installed in this conda environment.",
channel_layer)
if(check_all_present(str_output, ['Mamba Install Complete'])):
if (check_all_present(str_output, ['Mamba Install Complete'])):
break
if(check_all_present(str_output, ['Found conflicts!'])):
if (check_all_present(str_output, ['Found conflicts!'])):
send_notification("Mamba install found conflicts."
"Please try running the following command in your terminal's"
"conda environment to attempt a manual installation : "
Expand All @@ -168,16 +167,14 @@ def conda_install(app_metadata, app_channel,app_label,app_version, channel_layer

def begin_install(installData, channel_layer, app_workspace):

# resource = get_resource(installData["name"], app_workspace)
resource = get_resource(installData["name"], installData['channel'], installData['label'], app_workspace)

resource = get_resource_new(installData["name"],installData['channel'],installData['label'], app_workspace)

send_notification("Starting installation of app: " + resource['name'] + " from store "+ installData['channel'] + " with label "+ installData['label'] , channel_layer)
send_notification("Starting installation of app: " + resource['name'] + " from store " + installData['channel'] +
" with label " + installData['label'], channel_layer)
send_notification("Installing Version: " + installData["version"], channel_layer)


try:
conda_install(resource,installData['channel'],installData['label'], installData["version"], channel_layer)
conda_install(resource, installData['channel'], installData['label'], installData["version"], channel_layer)
except Exception as e:
logger.error("Error while running conda install")
logger.error(e)
Expand Down
Loading

0 comments on commit 455f665

Please sign in to comment.