Hello Arif,
That's a really fascinating question. It sounds like you're a good-way there. I'll write from a generic perspective first for those on the list, and see if it takes you where you need.
First, when you're writing a new command for the FPR, we know that we're asking Archivematica to run some tool that is going to run on the same server that you are running the MCP Client. So, if you wanted to garner output from the Linux file command, file must be available on the path.
In the case of Python we need to do the same, but what's often not so obvious is that Archivematica, as a Python application, is running in its own virtual environment (there is one for each component, including MCP Client). That means within the virtual environment we can see the path, but it can also only see the modules installed in there.
If you inspect the status of the MCP Client service, you can see where the the virtual environment is:
[artefactual@analyst-vm ~]$ service archivematica-mcp-client status
Redirecting to /bin/systemctl status archivematica-mcp-client.service
● archivematica-mcp-client.service - Archivematica MCP Client Service
Loaded: loaded (/etc/systemd/system/archivematica-mcp-client.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-05-05 15:44:26 CEST; 1 weeks 2 days ago
Main PID: 2964 (python)
CGroup: /system.slice/archivematica-mcp-client.service
├─1307 /usr/share/archivematica/virtualenvs/archivematica-mcp-client/bin/python /usr/lib/archivematica/MCPClient/archivematicaClient.py
└─2964 /usr/share/archivematica/virtualenvs/archivematica-mcp-client/bin/python /usr/lib/archivematica/MCPClient/archivematicaClient.py
So, for me, /usr/share/archivematica/virtualenvs/archivematica-mcp-client/bin/
We actually seem to only have the one script importing an additional module that's not in the standard Python library at the moment: Check against policy PLACEHOLDER_FOR_POLICY_FILE_NAME using MediaConch So it's not something we've done in scripts too much ourselves.
So where does that leave you?
I think modifying the virtual environment in a production environment/prototyping etc. would be risky (though you can always back it up and restore it). It's a little easier to work with new binaries in this regard. But then, the environment is still being mutated somewhat. So I think I'd persist with this in your test environment only.
As developers, if we're taking a prototype script (Bash, or Python), from testing to production, then we would persist that during deployment. In source control we'd update the
OSDeps (Operating System Dependencies) for bash-like scripts calling new binary utilities. For Python, we need to build the module into the setup for the virtual environment, so the
Python requirements.txt. (In that last link you'll see our Mediaconch import right at the top:
ammpc). Then when the `venv` is built, or rebuilt, the modules are available to you to run by the `pip install` commands used to stand up Archivematica.
But yep, I'd consider steering away from running pip in a new script itself. Though it's interesting to hear that it failed. It's also a pretty cool that you tried it. I might give that a whirl sometime.
Maybe have a look at what it would take from the advice above to see that the dependency is already available to your environment when you start the client.
i hope that helps. Let us know how it goes.
Happy hacking!
Ross