Problem using !include

0 votes
asked Jun 9, 2023 in Question / help by EGR
recategorized Jun 9, 2023

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
    }
@enduml

4. 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
@enduml

Output:

---------------------------------------------------------------------------
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
@enduml

Output:

---------------------------------------------------------------------------
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

commented Jun 14, 2023 by anonymous
Same suggestion?

Best Regards

2 Answers

+1 vote
answered Jun 15, 2023 by The-Lu (89,080 points)

Hello E., and all,

It seems that is not an issue on PlantUML core, but on your plugin or package usage.
Then, perhaps ask directly the author of the IPlantUML package, on:

Regards,
Th.

commented Jun 15, 2023 by EGR

Thanks Th!...

I'll tray contact https://pypi.org/project/IPlantUML/

Best Regards

commented Jun 23, 2023 by EGR
iplantuml is a wonderful ally for working in Jupyter and Colab notebook code cells.

I understand that it is a working project, but without updates since 2017.

I have not been able to contact the creator, to find out if it is possible to solve the problem of the use of the !include directive.

Best regards
0 votes
answered Jun 29, 2023 by EGR
Finally, I've managed to use !include directive from Github.
So far I have not been able to do it from Google Drive, nor as a file raised to the Colab environment.

Best regards
...