VSCode and jsonargparse error #18025
-
|
Hi everyone, I recently switchted to VSCode from PyCharm and I am facing currently an issue. If I try to debug my import sys
import os
from adiff.utils import train_util
import adiff.model.lightning.base_model
def cli_main():
# Start Training/Testing based on the args
data_dir = f'/home/{os.getlogin()}/Data/datasets'
logging_dir = f'/home/{os.getlogin()}/Data/lightning_logs'
default_cfg = ["config/debug_cfg.yaml"]
cmdline_args = [
"fit",
"--model", "DiffGen",
'--task', 'GEN',
'--data_dir', f'{data_dir}',
'--logging_dir', f'{logging_dir}',
'--data.dimensions', '2',
'--num_workers', '0',
'--data.batch_size=5',
'--data.dataset=cifar-10',
'--data.in_channels=3',
'--model.out_channels=3',
'--trainer.logger=False',
'--data.num_train_subj=10',
'--data.num_val_subj=10',
'--model.diffusion_mean_type=EPSILON',
'--model.diffusion_loss_type=SIMPLE',
'--model.diffusion_var_type=FIXED_LARGE',
'--model.ema_decay=0.9999',
'--trainer.max_steps=700000',
]
subcommands = ('fit', 'test', 'validate', 'predict')
parser_kwargs = {subcommand: {'default_config_files': default_cfg} for subcommand in subcommands}
cli = train_util.DiffLightningCLI(
model_class=adiff.model.lightning.base_model.BaseModel,
subclass_mode_model=True,
run=run,
seed_everything_default=123,
parser_kwargs=parser_kwargs,
save_config_kwargs={"overwrite": True,
"multifile": True},
args=cmdline_args)
# Shutdown
sys.exit()
if __name__ == "__main__":
import warnings
from lightning_fabric.utilities.warnings import PossibleUserWarning
with warnings.catch_warnings():
warnings.filterwarnings(
action='ignore',
category=PossibleUserWarning,
message='The dataloader,')
cli_main()I am aware that passing in the args like this is not recommended and is also only used in debugging and not in the final {
"version": "0.2.0",
"configurations": [
{
"name": "main.py",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/ADiff/adiff/main.py",
"console": "integratedTerminal",
"justMyCode": false,
"redirectOutput": false,
}
]
}I get the following error message: The command under the hood in VSCode uses However, if I run the exact same file using python directly without VSCode, the code runs as intended (as it was running on PyCharm). I am debugging remotely using ssh (I am running the same file with and without VSCode), made sure that the exact same conda environment is utilised with the following packages: jsonargparse: 4.22.1 It seems to me like a VSCode issue, hence why I am aware that this might not be the best place to ask that question but maybe someone has encountered a similar problem or could share their working I appreciate any input! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
I think this is not related to VSCode. I can reproduce the same when running from command line with: from lightning.pytorch.cli import LightningCLI
from lightning.pytorch.demos.boring_classes import DemoModel
def cli_main():
cmdline_args = [
"fit",
"--model", "DemoModel",
'--data.dimensions', '2',
]
cli = LightningCLI(
model_class=DemoModel,
subclass_mode_model=True,
run=True,
args=cmdline_args)
if __name__ == "__main__":
cli_main()The problem is "a dict without class_path but with init_args entry (class path given previously)". That is, The error message could be better. To request to improve that, please do in https://github.com/omni-us/jsonargparse/issues. |
Beta Was this translation helpful? Give feedback.
@mauvilsa I figured it out. It turned out that my default configuration file was not found due to an error in the
launch.jsonfile of VSCode. I provided the configuration as a relative path to themain.pyfile. However, thecwdwas set to the${workspaceFolder}, which is two folders above it (as I want to have all my different projects in the same workspace). This lead to not finding the respective default configuration file in_get_default_config_filesofjsonargparse/core.py.Your suggestion of having a more distinct error message could be helpful in the future but is included in the current error messages if one has more experience with the
jsonargparsemodule.Thank you for your help!
…