Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Allow the part column name to be specified on cli/config to avoid prompting during multi-column file import #41

Closed
cmidgley opened this issue Apr 5, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@cmidgley
Copy link
Contributor

cmidgley commented Apr 5, 2024

Background and use case

I am working on automating the workflow from my electronics design software to Inventree, including importing new parts. I currently export a single multi-column file which is used for part creation with inventree_part_import and for BOM import into Inventree. When using inventree_part_import -i false somefile.csv the user is required to manually select which column to use for the import, halting the automated process.

This feature request is to be able to specify the column name in advance of import to avoid the prompt.

User experience options

  1. Add a CLI option that specifies the column name, such as --import-column my-column-name.
  2. Add a config.yaml option that specifies the column name.
    This may be too rigid, as importing a file using a different column name would require editing the config file.
  3. A combination, where the config file specifies the default, but the CLI can override it including some syntax such as --import-column false or --import-column default to ignore it.
    While the most flexible approach, it feels like overkill for a low-use feature.

My recommendation is option 1. I'm willing to do a pull-request if approved.

@30350n
Copy link
Owner

30350n commented Apr 5, 2024

Currently columns named "Manufacturer Part Number" or "MPN" will already be picked up automatically:

MPN_HEADERS = ("Manufacturer Part Number", "MPN")

What do you use in your BOM files? If it seems reasonable enough, we could simply add it to that list. Otherwise I think I'd prefer exposing this as a config option (2.).

This may be too rigid, as importing a file using a different column name would require editing the config file.

This wouldn't be a problem in this case, as you could add multiple column names.

@30350n 30350n self-assigned this Apr 5, 2024
@30350n 30350n added the enhancement New feature or request label Apr 5, 2024
@cmidgley
Copy link
Contributor Author

cmidgley commented Apr 5, 2024

Didn't know about that capability with multiple pre-named header columns - very helpful.

I use the same column headers as InvenTree BOM, which include part_id and part_ipn. In the current implementation, it might make sense to add part_id to that list for compatibility, but that wouldn't address my issue.

As we've been discussing (#38), I use IPN which means the field I care about is part_ipn (mapping to the standard BOM fields). This is working well with my patched version of inventree_part_import, but it would be inappropriate for it to be in the default list.

Changing MPN_HEADERS to optionally read from config.yaml and default as before sounds like a simple, consistent, and non-disruptive approach. What do you think? Is it worth adding, or too limited a use case to be worth the code maintenance?

@30350n
Copy link
Owner

30350n commented Apr 5, 2024

Optional config parameters are super simple to add, that's why I generally prefer them to extra CLI options ^^

There's a new auto_detect_columns configuration option now (standard yaml list).

@cmidgley
Copy link
Contributor Author

cmidgley commented Apr 6, 2024

Wonderful. Confirmed working with both the new default with part_id as well as the ability to override it with config.yaml.

@30350n
Copy link
Owner

30350n commented Apr 6, 2024

Perfect, thanks for confirming ^^

@30350n 30350n closed this as completed Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants