Have you ever wanted to create a new configuration in Automation Studio which is mostly made of reference files, only to find yourself spending a lot of time creating new files and folders one-at-a-time in order to duplicate the existing configuration? I definitely have, and so I’ve been working on a Python script to automate that process.
You can find the script in a repository at (GitHub - marcusbnr/AsConfigDuplicator: Duplicates an AS configuration and replaces config files with reference files). The ReadMe file includes a demonstration video. To use this script:
- Place the AsConfigDuplicator python script in the folder which also contains the AS project folder
- Run the script using Python >= 3.9.2
- Input the AS project name (the name of the project folder which holds the .apj file)
- Input the name of the configuration to be duplicated
- Input the name of the new configuration
After that, you’ll have an exact copy of your initial configuration except that all of the files in the Configuration View will not be copies, but instead references to the initial configuration. From there you can swap out the hardware if desired.
This is something that I’ve finished recently so I haven’t tested it on many projects yet. If you do try this out, please let me know if you run into any issues or have any other feedback. The script is open source so feel free to adapt it to your own needs as well.
Disclaimer: Before you run an automated script on your project files, make sure the project is backed up or committed to a version control system in order to avoid any unintended consequences.
Cool script Marcus!
Another thing that may not be often known about is that you can actually define reference packages in Automation Studio projects. This can be a huge benefit for example if you’ve made a copy of a configuration and you want to say, reference the entire MpView package of your main configuration. To do this, you can manually edit the Cpu.pkg file and simply add the
attribute to the package in question along with the path to the folder in question.
Modifying the mappView entry in the Cpu.pkg file from:
Sets my current configuration (inoSpace910) to reference the mappView folder defined in the “5PC910” configuration in my same project
This makes it very handy so that when you add a new file to your main configuration, you don’t need to go through and update the rest of your configurations by adding new referenced files.
edit: As mentioned later on in this thread - be careful in editing these files externally to Automation Studio. This is definitely an undocumented functionality. In general I’ve seen no adverse side effects however that doesn’t mean I’ve tested all possible combinations. I’d recommend to use git/source control to have backups and test thoroughly.
I did not know that. That’s really neat. That would have made my script a little simpler, but at least the end result is the same.
An alternative to using AS configurations would probably to use e.g. git branches. Then you wouldn’t have to care about what Automation Studio supports and what not. But that’s just a thought…
Not exactly the same, if you use the reference to package when you add a file inside the original configuration this file is automatically also available inside the copied configuration, this is nice in particular for mappview