nbautoexport icon indicating copy to clipboard operation
nbautoexport copied to clipboard

Proposal: additive `configure`

Open cccntu opened this issue 4 years ago • 2 comments

  • nbautoexport version: 0.2.1
  • Python version: 3.9.1
  • Operating System: Ubuntu 18.04.1

Description

In the clean doc: https://nbautoexport.drivendata.org/cleaning/ I tried to add a folder to exclude, and it overwrote my old non-default export_formats config. I think it would be more natural to not have everything overwritten.

What I Did

❯ cat notebooks/.nbautoexport
{
  "export_formats": [
    "script",
    "html"
  ],
  "organize_by": "extension",
}
❯ nbautoexport configure notebooks/ \
    --clean-exclude 'report/*'
Detected existing autoexport configuration at notebooks/.nbautoexport. If you wish to overwrite, use the --overwrite flag.
❯ nbautoexport configure notebooks/ --overwrite \
    --clean-exclude 'report/*'
❯ cat notebooks/.nbautoexport
{
  "export_formats": [
    "script"
  ],
  "organize_by": "extension",
  "clean": {
    "exclude": [
      "report/*"
    ]
  }
}

cccntu avatar Jan 11 '21 02:01 cccntu

There are two ways I see this going:


1. Always replace a configured option.

{
  "export_formats": [
    "script"
  ],
  "organize_by": "extension",
}

nbautoexport configure notebooks/ -f html

would give you

{
  "export_formats": [
    "html"
  ],
  "organize_by": "extension",
}

2. Lists are additive

{
  "export_formats": [
    "script"
  ],
  "organize_by": "extension",
}

nbautoexport configure notebooks/ -f html

would give you

{
  "export_formats": [
    "script",
    "html"
  ],
  "organize_by": "extension",
}

Not sure which kind of behavior is more intuitive and easy-to-use.

As for the old behavior of replacing a file entirely, we could always tie that to the --overwrite flag or a new flag like --replace or something.

jayqi avatar Feb 20 '21 20:02 jayqi

Update: I no longer think there is a need for this functionality. I just directly edit the config file like other dotfiles.

I think we just need to prompt user to optionally edit the config file themselves when existing file is detected. Maybe add documentation for the syntax.

cccntu avatar Feb 22 '21 05:02 cccntu