Skip to content
Snippets Groups Projects
Commit 3175b286 authored by Ryan Godwin's avatar Ryan Godwin
Browse files

Removed the utils submodule and pulled in the corresponding utils

parent 181b17d7
No related branches found
No related tags found
1 merge request!2Feature/execute
......@@ -9,7 +9,7 @@ import typer
from config import config
from config.config import logger
from hrvmeg import compare, meg_to_ica, plotter, predict, preprocess_ecg
from py_utils import config_utils, get_data, print_info
from utils import config_utils, get_data, print_info
# Experiment Name
experiment_name = "Testing part 1"
......
import json
from urllib.request import urlopen
import numpy as np
def load_json_from_url(url):
"""
It loads JSON data from a URL
Args:
url: The URL to load JSON data from.
Returns:
A dictionary of the JSON data.
"""
data = json.loads(urlopen(url).read())
return data
def load_dict(filepath):
"""
Load a dictionary from a JSON's filepath.
Args:
filepath: The filepath to the JSON file.
Returns:
A dictionary.
"""
with open(filepath, "r") as fp:
d = json.load(fp)
return d
def save_dict(d, filepath, cls=None, sortkeys=False):
"""
It saves a dictionary to a specific location.
Args:
d: The dictionary to save.
filepath: The path to the file to save the dictionary to.
cls: A custom JSONEncoder subclass. If specified, the object will use this encoder instead of the
default.
sortkeys: If True, the keys of the dictionary are sorted before writing. Defaults to False
"""
with open(filepath, "w") as fp:
json.dump(d, indent=2, fp=fp, cls=cls, sort_keys=sortkeys)
def set_seeds(seed=42):
"""
`set_seeds` sets the seed for reproducibility
Args:
seed: The seed for the random number generator. Defaults to 42
"""
# Set seeds
seed = np.random.seed(seed)
return seed
from pathlib import Path
"""
It takes a list of file extensions and returns a list of all files in the current directory that
match those extensions
:param extensions: a list of file extensions to search for
:return: A list of all folders in the current directory with the extensions specified in the list.
"""
def get_folders(filepath, extensions):
all_folders = []
location_of_interest = Path(filepath).absolute()
for ext in extensions:
all_folders.extend(location_of_interest.rglob(ext))
return all_folders
def get_files(folders_to_search, extension):
all_files = []
for folder in folders_to_search:
# print(folder)
text_file_generators = folder.glob(extension)
for text_file in text_file_generators:
all_files.append(text_file)
return all_files
def print_experiment_info(experiment):
"""
This function prints the name, experiment ID, artifact location, and lifecycle stage of an
experiment.
Args:
experiment: The experiment object that contains the mlflow experiment information.
"""
print("Name: {}".format(experiment.name))
print("Experiment ID: {}".format(experiment.experiment_id))
print("Artifact Location: {}".format(experiment.artifact_location))
print("Lifecycle_stage: {}".format(experiment.lifecycle_stage))
def print_run_info(run):
"""
It prints out the run_id, experiment_id, params, artifact_uri, and status of a run
Args:
run: The run object that contains the mlflow run information.
"""
print("run_id: {}".format(run.info.run_id))
print("experiment_id: {}".format(run.info.experiment_id))
print("params: {}".format(run.data.params))
print("artifact_uri: {}".format(run.info.artifact_uri))
print("status: {}".format(run.info.status))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment