I'm using Google Colab as my working environment. It works properly for creating diagrams using Plantuml, but I cannot make the !include directive work.
Below, I describe the procedure I’ve used, maybe I made an error or forgot something:
1. Prepare Colab to use Plantuml, in a code cell I execute:
!pip install iplantuml --upgrade plantuml
import iplantuml
%load_ext iplantuml
Output:
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Requirement already satisfied: iplantuml in /usr/local/lib/python3.10/dist-packages (0.1.1)
Requirement already satisfied: plantuml in /usr/local/lib/python3.10/dist-packages (0.3.0)
Requirement already satisfied: plantweb in /usr/local/lib/python3.10/dist-packages (from iplantuml) (1.2.1)
Requirement already satisfied: httplib2 in /usr/local/lib/python3.10/dist-packages (from plantuml) (0.21.0)
Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in /usr/local/lib/python3.10/dist-packages (from httplib2->plantuml) (3.0.9)
Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from plantweb->iplantuml) (1.16.0)
Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from plantweb->iplantuml) (2.27.1)
Requirement already satisfied: docutils in /usr/local/lib/python3.10/dist-packages (from plantweb->iplantuml) (0.16)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->plantweb->iplantuml) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->plantweb->iplantuml) (2022.12.7)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/dist-packages (from requests->plantweb->iplantuml) (2.0.12)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->plantweb->iplantuml) (3.4)
The iplantuml module is not an IPython extension.
2. Verification of Plantuml operation in Colab, in a code cell we execute:
%%plantuml
@startuml
%version()
@enduml
Output:
1 2023 9beta2
3. Create a file named IncludeTest.puml, in plain text format, on my laptop, with the following contents:
@startuml
class customer <<Entity>> {
- id :integer {unique} {not null}
- name: string
+f1(id :integer, name :string) :boolean
}
@enduml4. First test, I upload the IncludeTest.puml file to Google Drive and perform the !include test, with the following script in a Colab code cell:
%%plantuml
@startuml
!include https://drive.google.com/file/d/1dYup5QkaXAAMEuVakTllnBuY3l0O2U70
@endumlOutput:
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
<ipython-input-4-80e3e438e049> in <cell line: 1>()
----> 1 get_ipython().run_cell_magic('plantuml', '', '@startuml\n!include https://drive.google.com/file/d/1dYup5QkaXAAMEuVakTllnBuY3l0O2U70\nclass A\n@enduml\n')
5 frames
/usr/local/lib/python3.10/dist-packages/google/colab/_shell.py in run_cell_magic(self, magic_name, line, cell)
332 if line and not cell:
333 cell = ' '
--> 334 return super().run_cell_magic(magic_name, line, cell)
335
336
/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2471 with self.builtin_trap:
2472 args = (magic_arg_s, cell)
-> 2473 result = fn(*args, **kwargs)
2474 return result
2475
/usr/local/lib/python3.10/dist-packages/iplantuml/__init__.py in plantuml(line, cell)
99 output = None
100 if use_web:
--> 101 output = plantuml_web(uml_path)
102 else:
103 plantuml_path = os.path.abspath(args.plantuml_path or PLANTUMLPATH)
/usr/local/lib/python3.10/dist-packages/iplantuml/__init__.py in plantuml_web(*file_names, **kwargs)
66 "auto"] + list(file_names)
67
---> 68 return _exec_and_get_paths(cmd, file_names)
69
70
/usr/local/lib/python3.10/dist-packages/iplantuml/__init__.py in _exec_and_get_paths(cmd, file_names)
30
31 def _exec_and_get_paths(cmd, file_names):
---> 32 subprocess.check_call(cmd, shell=False, stderr=subprocess.STDOUT)
33
34 return [os.path.splitext(f)[0] + ".svg" for f in file_names]
/usr/lib/python3.10/subprocess.py in check_call(*popenargs, **kwargs)
367 if cmd is None:
368 cmd = popenargs[0]
--> 369 raise CalledProcessError(retcode, cmd)
370 return 0
371
CalledProcessError: Command '['plantweb', '--format', 'auto', '035c2bfe-bb99-4c8e-98c9-c5916697f4e3.uml']' returned non-zero exit status 1.5. Second test, I upload the IncludeTest.puml file to the Colab environment in /content/IncludeTest.puml and perform the !include test, with the following script in a Colab code cell:
%%plantuml
@startuml
!include /content/IncludeTest.puml
@endumlOutput:
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
<ipython-input-5-a1dbb4ae30ea> in <cell line: 1>()
----> 1 get_ipython().run_cell_magic('plantuml', '', '@startuml\n!include /content/IncludeTest.puml\n@enduml\n')
5 frames
/usr/local/lib/python3.10/dist-packages/google/colab/_shell.py in run_cell_magic(self, magic_name, line, cell)
332 if line and not cell:
333 cell = ' '
--> 334 return super().run_cell_magic(magic_name, line, cell)
335
336
/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2471 with self.builtin_trap:
2472 args = (magic_arg_s, cell)
-> 2473 result = fn(*args, **kwargs)
2474 return result
2475
/usr/local/lib/python3.10/dist-packages/iplantuml/__init__.py in plantuml(line, cell)
99 output = None
100 if use_web:
--> 101 output = plantuml_web(uml_path)
102 else:
103 plantuml_path = os.path.abspath(args.plantuml_path or PLANTUMLPATH)
/usr/local/lib/python3.10/dist-packages/iplantuml/__init__.py in plantuml_web(*file_names, **kwargs)
66 "auto"] + list(file_names)
67
---> 68 return _exec_and_get_paths(cmd, file_names)
69
70
/usr/local/lib/python3.10/dist-packages/iplantuml/__init__.py in _exec_and_get_paths(cmd, file_names)
30
31 def _exec_and_get_paths(cmd, file_names):
---> 32 subprocess.check_call(cmd, shell=False, stderr=subprocess.STDOUT)
33
34 return [os.path.splitext(f)[0] + ".svg" for f in file_names]
/usr/lib/python3.10/subprocess.py in check_call(*popenargs, **kwargs)
367 if cmd is None:
368 cmd = popenargs[0]
--> 369 raise CalledProcessError(retcode, cmd)
370 return 0
371
CalledProcessError: Command '['plantweb', '--format', 'auto', 'bbbb9226-8689-47b0-9317-631e7d7f3cda.uml']' returned non-zero exit status 1.As you can see, in both tests, steps 4 and 5, I have been unable to make the !include directive work.
Any suggestions?
Best regards