Git Product home page Git Product logo

g2command's Introduction

g2command

If you are beginning your journey with Senzing, please start with Senzing Quick Start guides.

You are in the Senzing Garage where projects are "tinkered" on. Although this GitHub repository may help you understand an approach to using Senzing, it's not considered to be "production ready" and is not considered to be part of the Senzing product. Heck, it may not even be appropriate for your application of Senzing!

Overview

This Dockerfile is a wrapper over Senzing's G2Command.py.

Contents

  1. Expectations
  2. Demonstrate using Docker
    1. Configuration
    2. Database support
    3. Run docker container
  3. References

Legend

  1. ๐Ÿค” - A "thinker" icon means that a little extra thinking may be required. Perhaps you'll need to make some choices. Perhaps it's an optional step.
  2. โœ๏ธ - A "pencil" icon means that the instructions may need modification before performing.
  3. โš ๏ธ - A "warning" icon means that something tricky is happening, so pay attention.

Expectations

  • Space: This repository and demonstration require 1 GB free disk space.
  • Time: Budget 40 minutes to get the demonstration up-and-running, depending on CPU and network speeds.
  • Background knowledge: This repository assumes a working knowledge of:

Demonstrate using Docker

Configuration

Configuration values specified by environment variable or command line parameter.

Database support

๐Ÿค” Optional: Some database need additional support. For other databases, these steps may be skipped.

  1. Db2: See Support Db2 instructions to set SENZING_OPT_IBM_DIR_PARAMETER.
  2. MS SQL: See Support MS SQL instructions to set SENZING_OPT_MICROSOFT_DIR_PARAMETER.

Run docker container

  1. Run docker container. Example:

    sudo docker run \
      --interactive \
      --rm \
      --tty \
      ${SENZING_OPT_IBM_DIR_PARAMETER} \
      ${SENZING_OPT_MICROSOFT_DIR_PARAMETER} \
      senzing/g2command

References

g2command's People

Contributors

antaenc avatar dependabot[bot] avatar docktermj avatar jaeadams avatar kernelsam avatar ryanbasile avatar sammacy avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

g2command's Issues

Allow flag names to be used with G2Command

Description
CURRENT BEHAVIOR:
Flags must be entered as their integer value, determined by the bitwise operator expression for the flag.

From G2Engine.py:

G2_SEARCH_INCLUDE_FEATURE_SCORES = ( 1 << 26 )
which is 67108864 (2 to the power of 26 )

G2Command.py usage:

searchByAttributesV2 '{"NAME_FULL":"BOBBY JONES"}' 67108864
RECOMMENDED BEHAVIOR:
We should allow folks to use the actual flag name, the flag integer value, or a combination of them both for multiples flags.

G2Command.py usage:

searchByAttributesV2 '{"NAME_FULL":"BOBBY JONES"}' G2_SEARCH_INCLUDE_FEATURE_SCORES

Add send-to-file / send-prior-to-file and clipboard

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Add autocomplete for engine flags

Currently commands that take flags only accept an int value, add functionality to use engine flag names and enable auto complete for them.

Migrate from G2Engine.xxxxV2 methods

See senzing-garage/g2-sdk-python#105

Examples:

g2command/G2Command.py:            self.g2_module.searchByAttributesV2(args.jsonData,args.flags,response)
g2command/G2Command.py:            self.g2_module.getEntityByEntityIDV2(args.entityID,args.flags,response)
g2command/G2Command.py:            self.g2_module.findPathByEntityIDV2(args.startEntityID,args.endEntityID,args.maxDegree,args.flags,response)
g2command/G2Command.py:            self.g2_module.findNetworkByEntityIDV2(args.entityList,args.maxDegree,args.buildOutDegree,args.maxEntities,args.flags,response)
g2command/G2Command.py:            self.g2_module.findPathExcludingByEntityIDV2(args.startEntityID,args.endEntityID,args.maxDegree,args.excludedEntities,args.flags,response)
g2command/G2Command.py:            self.g2_module.findPathIncludingSourceByEntityIDV2(args.startEntityID,args.endEntityID,args.maxDegree,args.excludedEntities,args.requiredDsrcs,args.flags,response)
g2command/G2Command.py:            self.g2_module.getEntityByRecordIDV2(args.dataSourceCode, args.recordID, args.flags,response)
g2command/G2Command.py:            self.g2_module.findPathByRecordIDV2(args.startDataSourceCode,args.startRecordID,args.endDataSourceCode,args.endRecordID,args.maxDegree,args.flags,response)
g2command/G2Command.py:            self.g2_module.findNetworkByRecordIDV2(args.recordList,args.maxDegree,args.buildOutDegree,args.maxEntities,args.flags,response)
g2command/G2Command.py:            self.g2_module.whyEntityByRecordIDV2(args.dataSourceCode,args.recordID,args.flags,response)
g2command/G2Command.py:            self.g2_module.whyEntityByEntityIDV2(args.entityID,args.flags,response)
g2command/G2Command.py:            self.g2_module.howEntityByEntityIDV2(args.entityID,args.flags,response)
g2command/G2Command.py:            self.g2_module.getVirtualEntityByRecordIDV2(args.recordList,args.flags,response)
g2command/G2Command.py:            self.g2_module.whyEntitiesV2(args.entityID1,args.entityID2,args.flags,response)
g2command/G2Command.py:            self.g2_module.whyRecordsV2(args.dataSourceCode1,args.recordID1,args.dataSourceCode2,args.recordID2,args.flags,response)
g2command/G2Command.py:            self.g2_module.findPathExcludingByRecordIDV2(args.startDataSourceCode,args.startRecordID,args.endDataSourceCode,args.endRecordID,args.maxDegree,args.excludedEntities,args.flags,response)
g2command/G2Command.py:            self.g2_module.findPathIncludingSourceByRecordIDV2(args.startDataSourceCode,args.startRecordID,args.endDataSourceCode,args.endRecordID,args.maxDegree,args.excludedEntities,args.requiredDsrcs,args.flags,response)
g2command/G2Command.py:            self.g2_module.getRecordV2(args.dataSourceCode, args.recordID, args.flags,response)

Senzing License as environment variable

Add support for taking the value of the SENZING_ENGINE_CONFIGURATION_JSON environment variable send it to a Senzing init(...) command. By doing this the Senzing License will be sent to Senzing.

The value of SENZING_ENGINE_CONFIGURATION_JSON will look something like this:

{
	"PIPELINE": {
		"CONFIGPATH": "/etc/opt/senzing",
		"LICENSESTRINGBASE64": "AQAAADgCAAAAAAAAU2...",
		"RESOURCEPATH": "/opt/senzing/g2/resources",
		"SUPPORTPATH": "/opt/senzing/data"
	},
	"SQL": {
                :
	}
}

The Senzing License will be passed in via the PIPELINE.LICENSESTRINGBASE64 value. By passing the entire SENZING_ENGINE_CONFIGURATION_JSON string to the init(...) function, the license will be passed to Senzing.

Example use of SENZING_ENGINE_CONFIGURATION_JSON:

Also see senzing-garage/community-roadmap#64

Generates an error when run in a senzingapi-tools container

I'm trying to test out the senzingapi-tools images (sshd, xterm, etc) but the tools don't seem to work.

My expectation is that I could set the following env var and that would supersede an ini file:

SENZING_ENGINE_CONFIGURATION_JSON={
  "PIPELINE": {
    "CONFIGPATH": "/etc/opt/senzing",
    "LICENSESTRINGBASE64": "",
    "RESOURCEPATH": "/opt/senzing/g2/resources",
    "SUPPORTPATH": "/opt/senzing/data"
  },
  "SQL": {
    "CONNECTION": "postgresql://postgres:postgres@senzing-postgres:5432:G2/"
  }
}

Running with G2Command.py:

root@3635fe2673af:/opt/senzing/g2/python# G2Command.py 
Traceback (most recent call last):
  File "/opt/senzing/g2/python/G2Command.py", line 2498, in <module>
    cmd_obj = G2CmdShell(debug_trace, args.histDisable, ini_file_name)
NameError: name 'ini_file_name' is not defined
When I look at the mentioned line of code in G2Command.py:
cmd_obj = G2CmdShell(debug_trace, args.histDisable, ini_file_name)

Line referenced:
https://github.com/Senzing/g2command/blob/main/G2Command.py#L2498
it seems to require an ini file?
We would have gotten here via the elif on line 2468, but the code below doesn't take into account g2module_params which is set on 2470 and in the other branches. Seems like the G2CmdShell on lines 2484 and 2498 should use g2module_params instead of ini_file_name. However, I'd need to look more closely at that class to see if it's possible.

Do I have the wrong expectations with the env var? seems that having an ini file is required for G2Command.py

G2Command.py should have better help documentation on flags

Jonas has asked that we improved the documentation around "flags" inside of G2Command.py. He noted the following command and example, where flags were mentioned, but no info was given.

(g2) 
(g2) exportCSVEntityReport
G2Command > exportEntityReport: error: the following arguments are required: -f/-flags

Export repository contents as CSV:  exportCSVEntityReport -f <flags> [-o <output_file>]

(g2)

Update Links

See senzing-garage/template-repository#40

g2command/README.md:   "[How to initialize Senzing with Docker](https://github.com/Senzing/knowledge-base/blob/main/HOWTO/initialize-senzing-with-docker.md)".
g2command/README.md:   "[How to initialize Senzing with Docker](https://github.com/Senzing/knowledge-base/blob/main/HOWTO/initialize-senzing-with-docker.md)".
g2command/README.md:1. [docker](https://github.com/Senzing/knowledge-base/blob/main/HOWTO/install-docker.md)
g2command/README.md:1. [git](https://github.com/Senzing/knowledge-base/blob/main/HOWTO/install-git.md)
g2command/README.md:1. [make](https://github.com/Senzing/knowledge-base/blob/main/HOWTO/install-make.md)

Add get database information command

So that we have a way to tell what database an instance is pointed to.

def getDBInfo(self, response, *args, **kwargs):
# type: () -> object,int
""" Retrieve JSON of DB information
"""

    responseBuf = c_char_p(addressof(tls_var.buf))
    responseSize = c_size_t(tls_var.bufSize)
    self._lib_handle.G2Diagnostic_getDBInfo.argtypes = [POINTER(c_char_p), POINTER(c_size_t), self._resize_func_def]
    ret_code = self._lib_handle.G2Diagnostic_getDBInfo(pointer(responseBuf), pointer(responseSize), self._resize_func)
    if ret_code == -1:
        raise G2ModuleNotInitialized('G2Diagnostic has not been successfully initialized')
    elif ret_code < 0:
        self._lib_handle.G2Diagnostic_getLastException(tls_var.buf, sizeof(tls_var.buf))
        raise TranslateG2ModuleException(tls_var.buf.value)

    response += tls_var.buf.value

Additional G2Command functionality

  • Pretty print
  • Colour pretty print
  • New processResponse() function and associated helper functions
  • Update docstrings with examples
  • Copy to file and/or clipboard capabilities
  • Auto completers

Help documentation for purgeRepository is incorrect

(g2cmd) help purgeRepository

Purge G2 repository:  purgeRepository [-n] [--purgeWithoutPrompt]

  Where:
    -n = Skip resetting the resolver

    --FORCEPURGE = Don't prompt before purging. USE WITH CAUTION!

(g2cmd) 

--purgeWithoutPrompt should be --FORCEPURGE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.