Skip to content

Commit

Permalink
Merge pull request #3 from vsbogd/merge-opencog-to-singnet
Browse files Browse the repository at this point in the history
Merge opencog -> singnet
  • Loading branch information
vsbogd authored Jan 31, 2020
2 parents b911637 + 76e26ac commit 2a70bee
Show file tree
Hide file tree
Showing 98 changed files with 2,667 additions and 2,946 deletions.
87 changes: 2 additions & 85 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ SET(Boost_USE_MULTITHREADED ON)
SET(MIN_BOOST 1.46)

# Required boost packages
FIND_PACKAGE(Boost ${MIN_BOOST} COMPONENTS date_time filesystem program_options regex serialization system thread REQUIRED)
FIND_PACKAGE(Boost ${MIN_BOOST} COMPONENTS filesystem system REQUIRED)

IF(Boost_FOUND)
SET(Boost_FOUND_SAVE 1)
Expand Down Expand Up @@ -225,91 +225,8 @@ ENDIF (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR)

# ----------------------------------------------------------
# Python and Cython
#
# NOTE: Python interpreter is needed for runing python unit tests,
# and for running the FindCython module.
#
# Search for Python3 first, and use that, if found. Else use Python2.
# To use Python2 only from the build directory run the following
# rm CMakeCache.txt && cmake -DCMAKE_DISABLE_FIND_PACKAGE_Python3Interp=TRUE ..

FIND_PACKAGE(Python3Interp)
IF (3.4.0 VERSION_LESS "${PYTHON3_VERSION_STRING}")
SET (HAVE_PY_INTERP 1)
SET (PYTHON_VER python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
MESSAGE(STATUS "Python ${PYTHON3_VERSION_STRING} interpreter found.")
ENDIF()

IF (NOT HAVE_PY_INTERP)
FIND_PACKAGE(PythonInterp)
IF (2.7.0 VERSION_LESS ${PYTHON_VERSION_STRING})
SET (HAVE_PY_INTERP 1)
SET (PYTHON_VER python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
MESSAGE(STATUS "Python ${PYTHON_VERSION_STRING} interpreter found.")
ENDIF()
ENDIF()

FIND_PACKAGE(PythonLibs)
IF (PYTHONLIBS_FOUND AND
((PYTHON3INTERP_FOUND AND 3.4.0 VERSION_LESS ${PYTHONLIBS_VERSION_STRING})
OR
(2.7.0 VERSION_LESS ${PYTHONLIBS_VERSION_STRING})))
SET (HAVE_PY_LIBS 1)
MESSAGE(STATUS "Python ${PYTHONLIBS_VERSION_STRING} libraries found.")
ELSE()
MESSAGE(STATUS "Python libraries NOT found.")
ENDIF()

# Cython is used to generate python bindings.
IF(HAVE_PY_INTERP)
FIND_PACKAGE(Cython 0.23.0)

IF (CYTHON_FOUND AND HAVE_PY_LIBS)
ADD_DEFINITIONS(-DHAVE_CYTHON)
SET(HAVE_CYTHON 1)

# Find python destination dir for python bindings
# because it may differ on each operating system.
EXECUTE_PROCESS(
COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/get_python_lib.py" "${CMAKE_INSTALL_PREFIX}"
OUTPUT_VARIABLE PYTHON_DEST
)

# Replace new line at end
STRING(REPLACE "\n" "" PYTHON_DEST "${PYTHON_DEST}")
IF ("${PYTHON_DEST}" STREQUAL "")
MESSAGE(FATAL_ERROR "Python destination dir not found")
ELSE ("${PYTHON_DEST}" STREQUAL "")
MESSAGE(STATUS "Python destination dir found: ${PYTHON_DEST}" )
ENDIF ("${PYTHON_DEST}" STREQUAL "")

# thunk
SET(PYTHON_ROOT "${PYTHON_DEST}")
SET(PYTHON_DEST "${PYTHON_DEST}/opencog")

MESSAGE(STATUS
"Python install dir: ${PYTHON_DEST}" )

ELSE (CYTHON_FOUND AND HAVE_PY_LIBS)
IF(NOT CYTHON_FOUND)
MESSAGE(STATUS "Cython executable not found.")
ENDIF(NOT CYTHON_FOUND)
ENDIF (CYTHON_FOUND AND HAVE_PY_LIBS)

# Nosetests will find and automatically run python tests.
IF (PYTHON3INTERP_FOUND)
FIND_PROGRAM(NOSETESTS_EXECUTABLE nosetests3)
ELSE ()
FIND_PROGRAM(NOSETESTS_EXECUTABLE nosetests-2.7)
ENDIF ()
IF (NOT NOSETESTS_EXECUTABLE)
MESSAGE(STATUS "nosetests not found: needed for python tests")
ENDIF ()
IF (NOSETESTS_EXECUTABLE AND CYTHON_FOUND AND HAVE_PY_LIBS)
SET(HAVE_NOSETESTS 1)
MESSAGE(STATUS "Using nosetests executable " ${NOSETESTS_EXECUTABLE})
ENDIF (NOSETESTS_EXECUTABLE AND CYTHON_FOUND AND HAVE_PY_LIBS)
ENDIF(HAVE_PY_INTERP)
include(OpenCogFindPython)

# -----------------------------------------------------------------------------
# XXX FIXME. The jsoncpp, TBB and ZeroMQ packages are needed by
Expand Down
99 changes: 48 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,50 @@ The main project site is at https://opencog.org

Overview
--------
The CogServer provides a network server and a job scheduler.
The network server provides a fast, efficient telnet interface,
giving access to scheme (guile) and python command-lines.
In particular, it is much faster (and more stable) than the native
guile read-evaluate-print-loop (REPL) network server.
Python does not even provide a networked REPL server.

Both can be used by multiple users at the same time, and provide
not only a convenient interface for ad-hoc issuing of commands,
but also provide a very good (and easy, and strong) way of doing
bulk data transfers. In particular, the transfer of multiple
megabytes of Atoms and (Truth)Values as UTF-8 (i.e. human-readable)
data is easy and efficient. In particular, it does not require
fiddling with complex binary formats or protocols or the use of
protocol libraries or API's.

The job scheduler is an experimental prototype for controlling
multiple threads and assigning thread processing priorities, in
an AtomSpace-aware fashion. It is in need of the caring love and
attention from an interested developer.
The CogServer provides a network command-line console server and
a job scheduler. The network console server provides a fast,
efficient telnet interface, giving access to scheme (guile) and
python command-lines. This itself is notable: by default, Python
does not allow multiple users to access it at the same time. As
to scheme/guile, there is an ice-9 REPL server, but the CogServer
is an order of magnitude faster, and infinitely more stable,
free of lockups, hangs and crashes.

Both Python and Scheme can be used by multiple users at the same
time, all obtaining access to the *same* AtomSpace. Thus, the
Cogserver provides not only a convenient interface for ad-hoc
data processing, but also provides a very good (and easy, and strong)
way of doing bulk data transfers. In particular, the transfer of
multiple megabytes of Atoms and (Truth)Values as UTF-8
(i.e. human-readable) data is easy and efficient. In particular,
it does not require fiddling with complex binary formats or
protocols or the use of protocol libraries or API's. (We're looking
at you, HTTP, REST, ZeroMQ, ProtoBuff and friends. You are all
very sophisticated, yes, but are hard to use. And sometimes painfully
slow.)

The job scheduler (aka 'MindAgents' or just 'Agents') is an
experimental prototype for controlling multiple threads and assigning
thread processing priorities, in an AtomSpace-aware fashion. It is in
need of the caring love and attention from an interested developer.

For more info, please consult the
[CogServer wiki page](https://wiki.opencog.org/w/CogServer).

Building and Running
--------------------
For platform dependent instruction on dependencies and building the
code, as well as other options for setting up development environments,
more details are found on the [Building Opencog
The CogServer is build exactly the same way that all other OpenCog
components are built:
```
clone https://github.com/opencog/cogserver
cd cogserver
mkdir build
cd build
cmake ..
make -j
```
For additional information on dependencies and general hand-holding
with the build, see the [building Opencog
wiki](http://wiki.opencog.org/wikihome/index.php/Building_OpenCog).

Prerequisites
Expand All @@ -57,25 +72,11 @@ be built and run.
to `sudo make install` at the end.

###### AtomSpace
> OpenCog Atomspace database and reasoning engine
> OpenCog AtomSpace database and reasoning engine
> http://github.com/opencog/atomspace
> It uses exactly the same build procedure as this package. Be sure
to `sudo make install` at the end.

Building OpenCog
----------------
Perform the following steps at the shell prompt:
```
cd to project root dir
mkdir build
cd build
cmake ..
make
```
Libraries will be built into subdirectories within build, mirroring
the structure of the source directory root.


Unit tests
----------
To build and run the unit tests, from the `./build` directory enter
Expand All @@ -84,17 +85,13 @@ To build and run the unit tests, from the `./build` directory enter
make test
```

CMake notes
-----------
Some useful CMake's web sites/pages:

- http://www.cmake.org (main page)
- http://www.cmake.org/Wiki/CMake_Useful_Variables
- http://www.cmake.org/Wiki/CMake_Useful_Variables/Get_Variables_From_CMake_Dashboards
- http://www.cmake.org/Wiki/CMakeMacroAddCxxTest
- http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware

Architecture
------------
See also these README's:

-Wno-deprecated is currently enabled by default to avoid a number of
warnings regarding hash_map being deprecated (because the alternative
is still experimental!)
* [network/README](opencog/cogserver/network/README.md)
* [cogserver/README](opencog/cogserver/server/README.md)
* [builtin-module/README](opencog/cogserver/modules/commands/README.md)
* [cython/README](opencog/cython/README.md)
* [agents-module/README](opencog/cogserver/modules/agents/README.md)
* [events-module/README](opencog/cogserver/modules/events/README.md)
6 changes: 1 addition & 5 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@

include(CMakePackageConfigHelpers)

#export(EXPORT CogServerTargets
# FILE "${CMAKE_CURRENT_BINARY_DIR}/CogServer/CogServerTargets.cmake"
#)

set(ConfigPackageLocation lib/cmake/CogServer)

install(EXPORT CogServerTargets
Expand Down Expand Up @@ -38,7 +34,7 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/lib/opencog-test.conf

# Place a default config file in a default location
# CONFDIR normally expands to /usr/local/etc/
# XXX: why is cogserver.conf installed if the default file name is opencog.conf?
# Install `opencog.conf` for backwards-compat.
INSTALL (FILES
cogserver.conf
opencog.conf
Expand Down
6 changes: 6 additions & 0 deletions lib/CogServerConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

include("@CMAKE_INSTALL_PREFIX@/lib/cmake/CogServer/CogServerTargets.cmake")

# libagents.so is in the modules directory
link_directories(
"@CMAKE_INSTALL_PREFIX@/lib/opencog/"
"@CMAKE_INSTALL_PREFIX@/lib/opencog/modules"
)
set(COGSERVER_LIBRARIES
agents
server
)

Expand Down
83 changes: 50 additions & 33 deletions lib/cogserver.conf
Original file line number Diff line number Diff line change
@@ -1,54 +1,71 @@
#
# This file is used by the guile bindings for the cogserver if no other
# config file is specified. That is, it is used when you say:
# cogserver.conf
# OpenCog CogServer configuration file.
#
# (use-modules (opencog cogserver))
# (start-cogserver)
#
# It can be treated as an example configuration for a production OpenCog
# server.
# This file is usually installed either as `/etc/cogserver.conf` or as
# `/usr/local/etc/cogserver.conf` and is used by the cogserver if no
# other config file is specified.
#
# ------------------------------------------------------------
# Cogserver configuration. The cogserver listens to TCP/IPv4 port 17001
# by default. Change this to over-ride.
# SERVER_PORT = 17001
LOG_FILE = /tmp/cogserver.log

# Other possible log levels are "error", "warn", "info", "debug" and "fine"
# ------------------------------------------------------------
# Logging configuration.
LOG_FILE = /tmp/cogserver.log
# Possible log levels are "error", "warn", "info", "debug" and "fine"
# LOG_LEVEL = debug
LOG_LEVEL = info
LOG_TO_STDOUT = false
# SERVER_CYCLE_DURATION = 100

# Use this command PROMPT when telnet/terminal doesn't support ANSI
# PROMPT = "opencog> "
# Prompt with ANSI color codes
# ------------------------------------------------------------
# CogServer shell prompt styles. The shell prompt is displayed after
# connecting to the cogserver TCP/IP port, e.g. by saying
# `telnet localhost 17001`.
#
# Option enabling ANSI color codes on terminal output. True by default.
# ANSI_ENABLED = true
#
# Prompt with ANSI color codes.
# ANSI_PROMPT = "opencog> "
# Use this guile PROMPT when telnet/terminal doesn't support ANSI
# SCM_PROMPT = "guile> "
# Prompt with ANSI color codes
#
# This prompt is used when the telnet/terminal doesn't support ANSI.
# PROMPT = "opencog> "
#
# Prompt for the guile scheme shell exposed by the cogserver.
# ANSI_SCM_PROMPT = "guile> "
# Global option so that modules know whether they should output ANSI color
# codes
# ANSI_ENABLED = true

# These are automatically loaded; they do not need to be specified.
#
# The guile prompt when telnet/terminal doesn't support ANSI.
# SCM_PROMPT = "guile> "
#
# ------------------------------------------------------------
# Cogserver dynamically-loadable modules.
#
# The core, basic modules are loaded by default. The `builtinreqs`
# provide the most basic support for the cogserver network shell.
# The `scheme-shell` and `py-shell` provide scheme and python shells,
# respectively, for the cogserver.
#
# For OSX, the .so suffix will be auto-converted to .dylib
# MODULES = opencog/modules/libbuiltinreqs.so,
# opencog/modules/libscheme-shell.so,
# opencog/modules/libpy-shell.so,
#
# Optional modules, not enabled by default
# ------------------------------------------------------------
# Cogserver agents module. The agents module is loaded by default.
# It has several configurable paramters. This does something. (What?)
# SERVER_CYCLE_DURATION = 100
#
# ------------------------------------------------------------
# Optional modules, not enabled by default.
# These are not provided by the cogserver; these are external
# components, and are mentioned here only for backward-compatibility.
#
# opencog/modules/libatomspacepublishermodule.so
# opencog/modules/libdimensionalembedding.so

# The sense-similarity tables hold precomputed values for the similarity
# of word WordNet-3.0 senses. These tables are referenced in
# nlp/wsd/SenseSimilaritySQL.cc These will *eventually* be replaced by
# a persistent opencog table of sense similarities. For now, they remain
# in use.
#
# SENSE_SIMILARITY_DB_NAME = "lexat"
# SENSE_SIMILARITY_DB_USERNAME = "linas"
# SENSE_SIMILARITY_DB_PASSWD = "asdf"

#
# Parameters for ZeroMQ AtomSpace Event Publisher
# ZMQ_EVENT_USE_PUBLIC_IP = TRUE
# ZMQ_EVENT_PORT = 5563
# ------------------------------------------------------------
6 changes: 4 additions & 2 deletions lib/opencog-test.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#
# This config file is used by various opencog unit tests.
# opencog-test.conf
# This config file is used by various CogServer unit tests.
#
# Pick a port number that doesn't conflict with a running server!
SERVER_PORT = 18123
LOG_FILE = opencog-test.log

LOG_FILE = opencog-test.log
LOG_LEVEL = debug
LOG_TO_STDOUT = true

MODULES = opencog/server/libbuiltinreqs.so,
opencog/shell/libscheme-shell.so

Expand Down
Loading

0 comments on commit 2a70bee

Please sign in to comment.