Code Comments, Getting Dirty Env, Naming
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import ast
|
||||
import configparser
|
||||
from distutils.util import strtobool
|
||||
from pathlib import Path
|
||||
from typing import Mapping, Dict
|
||||
|
||||
@ -14,7 +15,7 @@ from configparser import ConfigParser, DuplicateSectionError
|
||||
import hashlib
|
||||
from pytorch_lightning import Trainer
|
||||
|
||||
from ml_lib.utils.loggers import Logger
|
||||
from ml_lib.utils.loggers import LightningLogger
|
||||
from ml_lib.utils.tools import locate_and_import_class, auto_cast
|
||||
|
||||
|
||||
@ -27,6 +28,7 @@ def parse_comandline_args_add_defaults(filepath, overrides=None):
|
||||
parser.add_argument('--model_name', type=str)
|
||||
parser.add_argument('--data_name', type=str)
|
||||
parser.add_argument('--seed', type=str)
|
||||
parser.add_argument('--debug', type=strtobool)
|
||||
|
||||
# Load Defaults from _parameters.ini file
|
||||
config = configparser.ConfigParser()
|
||||
@ -52,12 +54,9 @@ def parse_comandline_args_add_defaults(filepath, overrides=None):
|
||||
found_data_class = locate_and_import_class(data_name, 'datasets')
|
||||
found_model_class = locate_and_import_class(model_name, 'models')
|
||||
|
||||
for module in [Logger, Trainer, found_data_class, found_model_class]:
|
||||
for module in [LightningLogger, Trainer, found_data_class, found_model_class]:
|
||||
parser = module.add_argparse_args(parser)
|
||||
|
||||
# This is obsolete
|
||||
# new_defaults.update(data_name=data_name, model_name=model_name)
|
||||
|
||||
args, _ = parser.parse_known_args(namespace=Namespace(**new_defaults))
|
||||
|
||||
args = vars(args)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import inspect
|
||||
from argparse import ArgumentParser
|
||||
from copy import deepcopy
|
||||
|
||||
import hashlib
|
||||
@ -5,16 +7,17 @@ from pathlib import Path
|
||||
|
||||
import os
|
||||
from pytorch_lightning.loggers.base import LightningLoggerBase
|
||||
from pytorch_lightning.loggers.neptune import NeptuneLogger
|
||||
from neptune.api_exceptions import ProjectNotFound
|
||||
|
||||
from pytorch_lightning.loggers.neptune import NeptuneLogger
|
||||
|
||||
from pytorch_lightning.loggers.csv_logs import CSVLogger
|
||||
from pytorch_lightning.utilities import argparse_utils
|
||||
|
||||
from ml_lib.utils.tools import add_argparse_args
|
||||
|
||||
|
||||
class Logger(LightningLoggerBase):
|
||||
class LightningLogger(LightningLoggerBase):
|
||||
|
||||
@classmethod
|
||||
def from_argparse_args(cls, args, **kwargs):
|
||||
@ -97,7 +100,7 @@ class Logger(LightningLoggerBase):
|
||||
They are editable after experiment is created (see: append_tag() and remove_tag()).
|
||||
Tags are displayed in the experiment’s Details and can be viewed in experiments view as a column.
|
||||
"""
|
||||
super(Logger, self).__init__()
|
||||
super(LightningLogger, self).__init__()
|
||||
|
||||
self.debug = debug
|
||||
self.owner = owner if not self.debug else 'testuser'
|
||||
|
@ -67,7 +67,7 @@ def locate_and_import_class(class_name, folder_path: Union[str, PurePath] = ''):
|
||||
return model_class
|
||||
except AttributeError:
|
||||
continue
|
||||
raise AttributeError(f'Check the Model name. Possible model files are:\n{[x.name for x in module_paths]}')
|
||||
raise AttributeError(f'Check the {folder_path.name} name. Possible files are:\n{[x.name for x in module_paths]}')
|
||||
|
||||
|
||||
def add_argparse_args(cls, parent_parser):
|
||||
|
Reference in New Issue
Block a user