Spawing in new SARL

27 views
Skip to first unread message

Sebastian Sardina

unread,
Feb 7, 2021, 3:54:39 PM2/7/21
to sarl
Hi!

After a crazy 2020 I am back with SARL for 2021, or so I hope. :-)

I have seen SARL is now at 0.11.0, and importantly is using JANUS 3.  That is great progress, congrats!

I am a bit scary to migrate my agent systems to that, but I decided to give it a try. I guess this will be the first question in a set of questions in the coming weeks ;-)

So, I first managed to replace the old io.janusproject.Boot but I have a problem with spawning agents:

val agent_UUID = spawn(TestAgt_Slave, 200)

That method was from io.sarl.core.DefaultContextInteractions

But I cannot find anything similar in LifeCycle that gives the id of the agent created.

All I can think is to generate a random UUID first and then use spawnInContext()
from LifeCycle, but how? How do I say "in the default context"? That method requires more than the UUID

Thanks!

Sebastian

galland.stephane

unread,
Feb 7, 2021, 4:59:58 PM2/7/21
to Sebastian Sardina, sarl
Dear Sebastian.

It's nice to exchange with you again.

Indeed, the new internal implementation of Janus implies changes in the API.

You have found the good approach. And you discovered that creating an uuid prior to the spawn call is the new way.

In order to spawn in the default context/space with the ID, the most simple way is to call spawnInContextWithID with the default context instance:

uses DefaultContextInteractions
uses Lifecyle
def fct {
    var id = UUID::randomUUID
    typeof(TestAgt_Slave).spawnInContextWithID(id, defaultContext)

    // use id as you want
}

Details on the spawning function are there : 

I think it may be interesting to add a FAQ entry on big changes in the API that are marked as deprecated but with too few explanation in the API documentation. I will post an issue shortly.

Regards.
Stephane

Prof. Dr. Stéphane GALLAND
Full Professor of Computer Science and Multiagent Systems 
Co-Founder and Deputy Director of CIAD

Laboratoire Connaissance et Intelligence Artificielle Distribuées
CIAD UMR 7533

Université de Technologie de Belfort-Montbéliard
13 rue Ernest Thierry-Mieg
90010 Belfort cedex, FRANCE

CIAD Site: www.ciad-lab.fr
Phone: +33 384 583 418 (work office)
Mobile: +33 662 274 442 (private)


-------- Message d'origine --------
De : Sebastian Sardina <ssar...@gmail.com>
Date : 07/02/2021 21:54 (GMT+01:00)
Objet : [SARL] Spawing in new SARL

--
You received this message because you are subscribed to the Google Groups "sarl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sarl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sarl/89e5e313-c5a9-4c7d-8f0f-c876a52737fcn%40googlegroups.com.

Sebastian Sardina

unread,
Feb 7, 2021, 5:45:10 PM2/7/21
to sarl
Hi Stephane,

As usual a pleasure to ask here, knowing that you are always there and with clear answers! This is good...

I was going to propose to build that FAQ, but I thought it was a bit rude to ask for more as soon as I show up...

So, I propose you something: 

While I am migrating my systems, I will be finding those issues here and there. When I found a solution, many times will be by asking you here, I will collect them into a FAQ. Then once we are finished we can port it to the SARL official doc? Here are the two I have encountered already:


OK so be ready to receive a few questions in the coming weeks ;-)

Thanks & looking forward aligning all my systems to SARL 0.11.0 and SRE 3.x!

Sebastian

Stéphane Galland

unread,
Feb 8, 2021, 2:46:38 AM2/8/21
to sarl
Dear Sebastian.

Thank you for the link I will get the content of this page as soon as you have finished your migration and notify me that you have found all the possible things to now.

One comment regarding the entry "Booting agents from Java": the official way to launch agents programmatically is not based on a direct access to the Janus framework (i.e. Boot).

In order to avoid any problems due to changes into the Janus implementation, and explain in Section 3 of the pointed webpage on SARL, it is preferable to use the SRE
utility class (http://www.sarl.io/docs/official/api/SRE.html) , as follows:

import io.sarl.bootstrap
...
var sre = SRE::bootstrap
sre.startAgent(typeof(MyAgent))

The SRE tool provides to you other functions for launching agents or the SRE without agent.

Regards.
Stéphane.

Sebastian Sardina

unread,
Feb 8, 2021, 5:54:46 AM2/8/21
to sarl
Fantastic Stephane! You are right and I guess I was so desperate to check if my systems would still run that I kept using Janus as before...

But I totally get it why you recommend the utility, I have adapted my code: it works with the SRE utility. I have updated the doc to state that mechanism first as the preferred way.

BTW, I think we need to import io.sarl.bootstrap.SRE

I am curious what would have happened with the Boot.offline (I cannot recall what was this) and Boot.verboseLevel. Are these fully gone? I guess so...

Yes, I suggest you wait until I have tested all very well and collected all changes...
Good news is that I managed to migrate several systems today with great success, they all seem to be working with just those two adaptations for booting from java and  spawning with an ID.

I will continue tomorrow with other larger systems, but everything seems solid at this point, which is great!!

I did leave 2 issues for the IDE ECLIPSE though. The major one is that it seems 0.11.0 does not pick up any SRE and I cannot even add one manually. Hence I cannot run my systems from the IDE. :-(

Continue tomorrow...

Thanks for the great support!

Stéphane Galland

unread,
Feb 8, 2021, 7:00:05 AM2/8/21
to sarl
You're right, SRE must be properly imported. It was a mismatch in my code.

Regarding Boot.offline, this parameter is not any more needed in the kernel of Janus v3. Indeed, the Janus v3 kernel is now based on a new plugin architecture (based on the Bootique API).
With this plugin API, we could write a core software (the kernel) with a minimum set of features and that could be extended with plugins by only adding these plugins on the classpath of the application. In the context of Janus, we decided to move the network features into a plugin. In this way, you could easily add the network feature (by adding the plugin jar file in the classpath, equivalent to Boot.offline = false), removing it from the classpath (equivalent to Boot.offline = true), or add another networking plugin that is based on another technology (e.g. MQTT, etc.).
The major consequency of this new internal architecture is that the Boot.offline function is not any more into the Janus kernel (i.e. the Boot class) but into the configuration of the networking plugin. This plugin is under validation by Nicolas (so it is not into version 0.11 of SARL). It will be back in 0.12.

Regarding Boot.veroseLevel, the SRE utility class provides the function. Please note that it must be called before any launch of agent since the configuration level of Janus is set at start up.

Regards.

Sebastian Sardina

unread,
Feb 8, 2021, 4:31:19 PM2/8/21
to sarl
Top answer, clap clap!

Have added all that explanation to the migration FAQ.

really nice design move, plugin-based will be so much better for future development!
Reply all
Reply to author
Forward
0 new messages