I have followed the steps described in Cartpool notebook, but when I come to training the cartpole agent running the following cell:
from azureml.core import RunConfiguration, ScriptRunConfig, Experiment
from azureml.core.runconfig import DockerConfiguration, RunConfiguration
training_algorithm = "PPO"
rl_environment = "CartPole-v0"
video_capture = True
if video_capture:
algorithm_config = '\'{"num_gpus": 0, "num_workers": 1, "monitor": true}\''
else:
algorithm_config = '\'{"num_gpus": 0, "num_workers": 1, "monitor": false}\''
script_name = 'cartpole_training.py'
script_arguments = [
'--run', training_algorithm,
'--env', rl_environment,
'--stop', '\'{"episode_reward_mean": 200, "time_total_s": 300}\'',
'--config', algorithm_config,
'--checkpoint-freq', '2',
'--checkpoint-at-end',
'--local-dir', './logs'
]
ray_environment = Environment.get(ws, name=ray_environment_name)
run_config = RunConfiguration(communicator='OpenMpi')
run_config.target = compute_target
run_config.node_count = 1
run_config.environment = ray_environment
command=["python", script_name, *script_arguments]
if video_capture:
command = ["xvfb-run -s '-screen 0 640x480x16 -ac +extension GLX +render' "] + command
run_config.environment_variables["SDL_VIDEODRIVER"] = "dummy"
training_config = ScriptRunConfig(source_directory='./files',
command=command,
run_config = run_config
)
training_run = experiment.submit(training_config)
I get the following error message:
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/batch/tasks/shared/LS_root/mounts/clusters/xxx/code/Users/yyy/files'
Do you get what is missing?
When the build fails of the environment variables creation, this error will occur. Instead of connecting the environment from the existing environment, we need to create the docker file.
The below code will be generated.
FROM mcr.microsoft.com/azureml/openmpi3.1.2-cuda10.2-cudnn8-ubuntu18.04
RUN pip install azureml-mlflow
ray_env_build_details.wait_for_completion(show_output=True)
After building the docker file if the case is successful go with the file location of the data and file and replace with the existing path.
If the screen is getting like above screen of the error, then the specific file path and directory error will be notified.
If the succeeded information is achieved, then we can access the data from the specific cluster. It will solve the error.
I am looking at emit_rule example in bazel source tree:
https://github.com/bazelbuild/examples/blob/5a8696429e36090a75eb6fee4ef4e91a3413ef13/rules/shell_command/rules.bzl
I want to add a data dependency to the custom rule. My understanding of dependency attributes documentation calls for data attr label_list to be used, but it does not appear to work?
# This example copied from docs
def _emit_size_impl(ctx):
in_file = ctx.file.file
out_file = ctx.actions.declare_file("%s.pylint" % ctx.attr.name)
ctx.actions.run_shell(
inputs = [in_file],
outputs = [out_file],
command = "wc -c '%s' > '%s'" % (in_file.path, out_file.path),
)
return [DefaultInfo(files = depset([out_file]),)]
emit_size = rule(
implementation = _emit_size_impl,
attrs = {
"file": attr.label(mandatory = True,allow_single_file = True,),
"data": attr.label_list(allow_files = True),
# ^^^^^^^ Above does not appear to be sufficient to copy data dependency into sandbox
},
)
With this rule emit_size(name = "my_name", file = "my_file", data = ["my_data"]) I want to see my_data copied to bazel-out/ before running the command. How do I go about doing this?
The data files should be added as inputs to the actions that need those files, e.g. something like this:
def _emit_size_impl(ctx):
in_file = ctx.file.file
out_file = ctx.actions.declare_file("%s.pylint" % ctx.attr.name)
ctx.actions.run_shell(
inputs = [in_file] + ctx.files.data,
outputs = [out_file],
# For production rules, probably should use ctx.actions.run() and
# ctx.actions.args():
# https://bazel.build/rules/lib/Args
command = "echo data is: ; %s ; wc -c '%s' > '%s'" % (
"cat " + " ".join([d.path for d in ctx.files.data]),
in_file.path, out_file.path),
)
return [DefaultInfo(files = depset([out_file]),)]
emit_size = rule(
implementation = _emit_size_impl,
attrs = {
"file": attr.label(mandatory = True, allow_single_file = True,),
"data": attr.label_list(allow_files = True),
},
)
BUILD:
load(":defs.bzl", "emit_size")
emit_size(
name = "size",
file = "file.txt",
data = ["data1.txt", "data2.txt"],
)
$ bazel build size
INFO: Analyzed target //:size (4 packages loaded, 9 targets configured).
INFO: Found 1 target...
INFO: From Action size.pylint:
data is:
this is data
this is other data
Target //:size up-to-date:
bazel-bin/size.pylint
INFO: Elapsed time: 0.323s, Critical Path: 0.02s
INFO: 2 processes: 1 internal, 1 linux-sandbox.
INFO: Build completed successfully, 2 total actions
$ cat bazel-bin/size.pylint
22 file.txt
#bazel_skylib//rules:native_binary.bzl defines the native_binary rule which can be used to wrap native executables inside a bazel target. I used it to wrap a packaging tool called packfolder.exe from the Sciter SDK.
I placed the binary into my source tree at third_party/sciter/packfolder.exe and wrote this BUILD file.
# third_party/sciter/BUILD
native_binary(name = "packfolder",
src = "packfolder.exe",
out = "packfolder.exe"
)
bazel run third_party/sciter:packfolder runs with no issues. Now I want to use this target inside my custom cc_sciter_resource rule.
# third_party/sciter/sciter_rules.bzl
def _impl(ctx):
in_files = ctx.files.srcs
output_file = ctx.actions.declare_file(ctx.label.name)
ctx.actions.run(
outputs = [output_file],
inputs = in_files,
arguments = [],
executable = ctx.executable.packfolder.path)
return DefaultInfo(files = depset([output_file]))
cc_sciter_resource = rule(
implementation = _impl,
attrs = {
"srcs": attr.label_list(),
"packfolder": attr.label(
default = Label("//third_party/sciter:packfolder"),
executable = True,
cfg = "exec"
),
}
)
The trouble is, when I try to build a target that uses this rule, say
cc_sciter_resource(
name = "hello_world_resource.cpp"
srcs = [...]
)
I get the following error.
ERROR: C:/users/marki/sciter-bazel/examples/BUILD:12:19: Action examples/hello_world_resource.cpp failed (Exit -1): packfolder.exe failed: error executing command
cd C:/users/marki/_bazel_marki/kiodv2fz/execroot/sciter_bazel
bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/third_party/sciter/packfolder.exe
Execution platform: #local_config_platform//:host. Note: Remote connection/protocol failed with: execution failed
Action failed to execute: java.io.IOException: ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\users\marki\_bazel_marki\kiodv2fz\execroot\sciter_bazel\bazel-out\x64_windows-opt-exec-2B5CBBC6\bin\third_party\sciter\packfolder.exe"): The system cannot find the file specified.
(error: 2)
Target //examples:hello_world_resource.cpp failed to build
The directory C:\users\marki\_bazel_marki\kiodv2fz\execroot\sciter_bazel\bazel-out\x64_windows-opt-exec-2B5CBBC6 does not exist on my computer. So the error is accurate, but I don't know how to resolve the issue.
--- sciter_rules.bzl
+++ sciter_rules.bzl
## -6,7 +6,7 ##
outputs = [output_file],
inputs = in_files,
arguments = [],
- executable = ctx.executable.packfolder.path)
+ executable = ctx.executable.packfolder)
return DefaultInfo(files = depset([output_file]))
cc_sciter_resource = rule(
ctx.executable.packfolder.path is just a string, so Bazel doesn't know that the packfolder executable needs to be added as an input to the action.
I'm trying to make a custom command in mod_admin_extra.erl. to fetch messages between 2 JIDs.
My command will look like this:-
ejabberdctl get_messages HOST FROM TO START_TIME END_TIME
The SQL query will be like:-
select * from archive where (username = FROM and bare_peer = TO) OR (username=TO and bare_peer = FROM) where created_at BETWEEN START_TIME AND END_TIME;
I went through this thread to understand how IQ query works and want to build a similar sort of a thing via the command and API.
How do I fire the query in the above function so as to fetch the messages between the conversations of 2 JIDs??
My response would be a list of dictionaries:-
[{from: jid1, to: jid2, body: Hello, created_at: T1}]
I would be in turn using the same command for the POST API to fetch messages.
UPDATE
As per the suggestion provided by #Badlop, I updated my function with
% ----------------- Custom Command Get Message ----------------------
#ejabberd_commands{name = get_message, tags = [stanza],
desc = "Get messages from a local or remote bare of full JID",
longdesc = "Get messages of a specific JID sent to a JID",
module = ?MODULE, function = get_message,
args = [{host, binary}, {from, binary}, {to, binary},
{start_time, binary}, {end_time, binary}],
args_example = [<<"localhost">>, <<"admin">>, <<"user1">>,
<<"2015-07-00T00:00:00Z">>, <<"2015-07-029T13:23:54Z">>],
args_desc = ["Host", "From JID", "Receiver JID", "Start Time", "End Time"],
result = {result, {
tuple, [{messages, list, {message, {tuple,
[
{timestamp, string},
{xml, string},
{txt, string},
{peer, integer},
{kind, integer},
{nick, string}
]}}},
{status, string},
{count, integer}]}}
},
% ----------------- Custom Command Ends -----------------------------
This is my function that gets called when the command is received.
% ----------------- Custom Function Get Message ----------------------
get_message(Host, From, To, StartTime, EndTime) ->
mod_mam:select(
Host,
jid:make(From, Host),
jid:make(From, Host),
[{start, xmpp_util:decode_timestamp(StartTime)},
{'end', xmpp_util:decode_timestamp(EndTime)},
{with, jid:make(To, Host)}],
#rsm_set{},
chat,
all
).
% ----------------- Custom Function Get Message ----------------------
However, it returns an error response:-
Unhandled exception occurred executing the command:
** exception error: no function clause matching
ejabberd_ctl:format_result([],
{messages,list,
{message,
{tuple,
[{timestamp,string},
{xml,string},
{peer,integer},
{kind,integer},
{nick,string}]}}}) (src/ejabberd_ctl.erl, line 405)
in function ejabberd_ctl:format_result/2 (src/ejabberd_ctl.erl, line 461)
in call from ejabberd_ctl:try_call_command/4 (src/ejabberd_ctl.erl, line 321)
in call from ejabberd_ctl:process2/4 (src/ejabberd_ctl.erl, line 274)
in call from ejabberd_ctl:process/2 (src/ejabberd_ctl.erl, line 252)
in call from rpc:'-handle_call_call/6-fun-0-'/5 (rpc.erl, line 197)
The query printed in the logs in as follow:-
2020-04-24 21:57:13.717746+05:30 [debug] SQL: "SELECT timestamp, xml, peer, kind, nick FROM archive WHERE username=E'admin' and server_host=E'localhost' and bare_peer=E'test#localhost' and timestamp >= 1587692943312536 and timestamp <= 1587779343312536 ORDER BY timestamp ASC ;"
2020-04-24 21:57:13.726745+05:30 [debug] SQL: "SELECT COUNT(*) FROM archive WHERE username=E'admin' and server_host=E'localhost' and bare_peer=E'test#localhost' and timestamp >= 1587692943312536 and timestamp <= 1587779343312536;"
This is database independent:
mod_mam:select(
<<"localhost">>,
jid:make(<<"user1">>, <<"localhost">>),
jid:make(<<"user1">>, <<"localhost">>),
[{start, xmpp_util:decode_timestamp(<<"2020-04-24T14:37:25Z">>)},
{'end', xmpp_util:decode_timestamp(<<"2020-04-24T14:37:30Z">>)},
{with, jid:make(<<"user2">>,<<"localhost">>)}],
#rsm_set{},
chat,
all
).
Umm, you were still far away, the command result was wrong, and the call result must be processed. what about this?
$ ejabberdctl get_mam_messages user1#localhost user2#localhost 2020-04-27T00:00:00Z 2020-04-27T23:59:59Z
Required patch:
diff --git a/src/mod_mam.erl b/src/mod_mam.erl
index 08a4059b4..d2d74913c 100644
--- a/src/mod_mam.erl
+++ b/src/mod_mam.erl
## -42,6 +42,7 ##
get_room_config/4, set_room_option/3, offline_message/1, export/1,
mod_options/1, remove_mam_for_user_with_peer/3, remove_mam_for_user/2,
is_empty_for_user/2, is_empty_for_room/3, check_create_room/4,
+ get_messages_command/4,
process_iq/3, store_mam_message/7, make_id/0, wrap_as_mucsub/2, select/7]).
-include("xmpp.hrl").
## -1355,8 +1356,29 ## get_jids(undefined) ->
get_jids(Js) ->
[jid:tolower(jid:remove_resource(J)) || J <- Js].
+get_messages_command(From, To, StartTime, EndTime) ->
+ FromJid = jid:decode(From),
+ {Stanzas, _, _} =
+ mod_mam:select(
+ FromJid#jid.lserver, FromJid, FromJid,
+ [{start, xmpp_util:decode_timestamp(StartTime)},
+ {'end', xmpp_util:decode_timestamp(EndTime)},
+ {with, jid:decode(To)}],
+ #rsm_set{}, chat, all),
+ [fxml:element_to_binary(xmpp:encode(Subels))
+ || {_, _, #forwarded{sub_els = [Subels]}} <- Stanzas].
+
get_commands_spec() ->
- [#ejabberd_commands{name = delete_old_mam_messages, tags = [purge],
+ [#ejabberd_commands{
+ name = get_mam_messages, tags = [mam],
+ desc = "Get archived messages of an account with another contact",
+ module = ?MODULE, function = get_messages_command,
+ args = [{from, binary}, {to, binary}, {start, binary}, {'end', binary}],
+ args_example = [<<"user1#localhost">>, <<"user2#example.org">>,
+ <<"2020-04-27T00:00:00Z">>, <<"2020-04-27T23:59:59Z">>],
+ args_desc = ["Local JID", "Contact JID", "Start Time", "End Time"],
+ result = {messages, {list, {message, string}}}},
+ #ejabberd_commands{name = delete_old_mam_messages, tags = [purge],
desc = "Delete MAM messages older than DAYS",
longdesc = "Valid message TYPEs: "
"\"chat\", \"groupchat\", \"all\".",
I'm trying to send sms using kannel & smppsim.
I use docker as container.
I use this kannel.conf:
group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
admin-allow-ip = "127.0.0.1;192.168.59.103"
box-allow-ip = "127.0.0.1;192.168.59.103"
group = smsc
smsc = smpp
smsc-id = SMPPSim
host = 192.168.59.103
port = 2775
transceiver-mode = 1
smsc-username = smppclient1
smsc-password = password
system-type = 'VMA'
#service-type = 'test'
interface-version = 34
#system-id = smppclient
preferred-smsc-id = SMPPSim
connect-allow-ip = 192.168.59.103
group = smsbox
bearerbox-host = bearerbox
sendsms-port = 13013
global-sender = 13013
group = sendsms-user
username = tester
password = foobar
group = sms-service
keyword = default
text = "No service specified"
when sending a request to send sms I get "0: Accepted for delivery"
I'm seeing these errors in smsbox log:
2015-03-21 20:20:52 [1] [3] DEBUG: Status: 202 Answer: <Sent.>
2015-03-21 20:20:52 [1] [3] DEBUG: Delayed reply - wait for bearerbox
2015-03-21 20:20:52 [1] [0] DEBUG: Got ACK (0) of 74f9cefe-db95-4b7d-aa99-f07395d32915
2015-03-21 20:20:52 [1] [0] DEBUG: HTTP: Resetting HTTPClient for `192.168.59.3'.
2015-03-21 20:20:52 [1] [1] ERROR: Error reading from fd 24:
2015-03-21 20:20:52 [1] [1] ERROR: System error 104: Connection reset by peer
2015-03-21 20:20:52 [1] [1] DEBUG: HTTP: Destroying HTTPClient area 0x7fe8d0000ad0.
Bearbox doesn't present any errors and seem to pass the message to smppsim, smppsim shows this in log:
21 Assessing state of 1 messages in the OutboundQueue
21 Message:2 state=DELIVERED
The sms is not sent, what could be wrong?
I think its a problem with your Kannel configuration file, specially with smsbox and later parts. I used following as smsbox
group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
global-sender = your sim number which you use in USB modem
sendsms-chars = "0123456789 +-"
log-file = "/var/log/kannel/smsbox.log"
log-level = 0
access-log = "/var/log/kannel/access.log"
and you can get my full configuration file from here. This worked fine for me.
This might be a problem of lоѕѕ оf thе соnnесtіоn оn thе rеmоtе ѕосkеt due tо а tіmеоut.
And SMPPSim is just a testing tool for kannel. It won't really send a message to your or mentioned mobile number. To send real messages you need to add either gsm modems or SMS operator details.
You can refer to userGuide from kannel.org.
To check your kannel status simply go to http://localhost:13000/status?password=password(password of your kannel)