def test_er_start(): httpretty.register_uri(httpretty.POST, stellar_addr_er, body=u'{"sessionId": "melon"}') httpretty.register_uri(httpretty.GET, stellar_addr_session, body=u'{"sessionId": "dummy_session_id"}') ss = st.create_session(url=stellar_addr) task = ss.er_start(graph=StellarGraph('graph.epgm', 'test_er_ori'), resolver=EntityResolution(), attribute_thresholds={}, label='test_er') assert task._session_id == "coordinator:sessions:dummy_session_id"
def test_er_error(monkeypatch): httpretty.register_uri(httpretty.POST, stellar_addr_er, body=u'{"sessionId": "melon"}') httpretty.register_uri(httpretty.GET, stellar_addr_session, body=u'{"sessionId": "dummy_session_id"}') monkeypatch.setattr( 'test_er.StrictRedis.get', lambda *_: u'{"status": "aborted", "er": {"output": "", "error": "testing abort"}}') ss = st.create_session(url=stellar_addr) with pytest.raises(SessionError): ss.entity_resolution(StellarGraph('graph.epgm', 'test_er'), EntityResolution())
def test_ingest(monkeypatch): httpretty.register_uri(httpretty.POST, stellar_addr_ingest, body=u'{"sessionId": "melon"}') httpretty.register_uri(httpretty.GET, stellar_addr_session, body=u'{"sessionId": "dummy_session_id"}') monkeypatch.setattr( 'test_ingestion.StrictRedis.get', lambda *_: u'{"status": "completed", "ingest": {"output": "test_path.epgm", "error":""}}') ss = st.create_session(url=stellar_addr) graph = ss.ingest(graph_schema(), graph_mappings(), 'test_ingest') assert graph.path == "test_path.epgm"
def test_er(monkeypatch): httpretty.register_uri(httpretty.POST, stellar_addr_er) httpretty.register_uri(httpretty.GET, stellar_addr_session, body=u'{"sessionId": "dummy_session_id"}') monkeypatch.setattr( 'test_er.StrictRedis.get', lambda *_: u'{"status": "er completed", "er": {"output": "test_path.epgm", "error":""}}') ss = st.create_session(url=stellar_addr) graph = ss.entity_resolution(StellarGraph('graph.epgm', 'test_er_ori'), EntityResolution(), label='test_er') assert graph.path == "test_path.epgm" assert graph.label == 'test_er_ori' # label unchanged
def test_nai_start(): httpretty.register_uri(httpretty.POST, stellar_addr_nai, body=u'{"sessionId": "melon"}') httpretty.register_uri(httpretty.GET, stellar_addr_session, body=u'{"sessionId": "dummy_session_id"}') ss = st.create_session(url=stellar_addr) task = ss.nai_start(StellarGraph('graph.epgm', 'test_nai_ori'), Node2Vec(), 'target_attr', 'type', [], 'test_nai') assert task._session_id == "coordinator:sessions:dummy_session_id"
def test_nai(monkeypatch): httpretty.register_uri(httpretty.POST, stellar_addr_nai) httpretty.register_uri(httpretty.GET, stellar_addr_session, body=u'{"sessionId": "dummy_session_id"}') monkeypatch.setattr( 'test_nai.StrictRedis.get', lambda *_: u'{"status": "nai completed", "nai": {"output": "test_path.epgm", "error":""}}' ) ss = st.create_session(url=stellar_addr) graph = ss.predict(StellarGraph('graph.epgm', 'test_nai_ori'), Node2Vec(), 'target_attr', 'type') assert graph.path == "test_path.epgm" assert graph.label == 'test_nai_ori'
def test_nai_error(monkeypatch): httpretty.register_uri(httpretty.POST, stellar_addr_nai, body=u'{"sessionId": "melon"}') httpretty.register_uri(httpretty.GET, stellar_addr_session, body=u'{"sessionId": "dummy_session_id"}') monkeypatch.setattr( 'test_nai.StrictRedis.get', lambda *_: u'{"status": "aborted", "nai": {"output": "", "error": "testing abort"}}' ) ss = st.create_session(url=stellar_addr) with pytest.raises(SessionError): ss.predict(StellarGraph('graph.epgm', 'test_nai_ori'), Node2Vec(), 'target_attr', 'type')
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ __license__ = "Apache 2.0" import stellar as st import networkx as nx """Create session""" ss = st.create_session(url="http://localhost:8000") """Create graph schema""" schema = st.create_schema() schema.add_node_type(name='Person', attribute_types={ 'full_name': 'string', 'address': 'string', 'risk': 'string' }) schema.add_edge_type(name='Association', src_type='Person', dst_type='Person') """Create data source mappings""" m_person = schema.node['Person'].create_map( path='/opt/stellar/data/risk_net/risk_net_names.csv', column='id', map_attributes={ 'full_name': 'name',
def test_ingest_start(): httpretty.register_uri(httpretty.POST, stellar_addr_ingest) httpretty.register_uri(httpretty.GET, stellar_addr_session, body=u'{"sessionId": "dummy_session_id"}') ss = st.create_session(url=stellar_addr) task = ss.ingest_start(graph_schema(), graph_mappings(), 'test_ingest') assert task._session_id == "coordinator:sessions:dummy_session_id"