Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public A loadArguments(String path) throws ZinggClientException, NoSuchObjectExc

@Override
public void writeArguments(String path, IZArgs args) throws ZinggClientException, NoSuchObjectException {
ArgumentsWriter<A> argumentsWriter = writerFactory.getArgumentsWriter(WriterType.JSON);
ArgumentsWriter<A> argumentsWriter = writerFactory.getArgumentsWriter(WriterType.FILE);
argumentsWriter.write(path, args);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public ArgumentsWriter<A> getArgumentsWriter(WriterType writerType) throws NoSuc
switch (writerType) {
case FILE:
return new FileArgumentsWriter<A>();
case JSON:
return new JsonStringArgumentsWriter<A>();
default:
throw new NoSuchObjectException("No such writer exists: " + writerType.name());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package zingg.common.client.arguments.writer;

public enum WriterType {
FILE,
JSON
FILE
}
13 changes: 0 additions & 13 deletions docs/pythonOss/markdown/_autosummary/zingg.client.Arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ This class helps supply match arguments to Zingg. There are 3 basic steps in any
| [`setTrainingSamples`](#zingg.client.Arguments.setTrainingSamples) | Method to set existing training samples to be matched. |
| [`setZinggDir`](#zingg.client.Arguments.setZinggDir) | Method to set the location for Zingg to save its internal computations and models. |
| [`writeArgumentsToJSON`](#zingg.client.Arguments.writeArgumentsToJSON) | Method to write JSON file from the object of this class |
| [`writeArgumentsToJSONString`](#zingg.client.Arguments.writeArgumentsToJSONString) | Method to create an object of this class from the JSON file and phase parameter value. |

#### \_\_init_\_()

Expand Down Expand Up @@ -166,15 +165,3 @@ Method to write JSON file from the object of this class

* **Parameters:**
**fileName** (*String*) – The CONF parameter value of ClientOption object or file address of json file

#### writeArgumentsToJSONString()

Method to create an object of this class from the JSON file and phase parameter value.

* **Parameters:**
* **fileName** (*String*) – The CONF parameter value of ClientOption object
* **phase** (*String*) – The PHASE parameter value of ClientOption object
* **Returns:**
The pointer containing address of the this class object
* **Return type:**
pointer([Arguments](#zingg.client.Arguments))
8 changes: 1 addition & 7 deletions python/docs/_autosummary/zingg.client.Arguments.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zingg.client.Arguments
zingg.client.Arguments
======================

.. currentmodule:: zingg.client
Expand Down Expand Up @@ -39,10 +39,4 @@
~Arguments.setTrainingSamples
~Arguments.setZinggDir
~Arguments.writeArgumentsToJSON
~Arguments.writeArgumentsToJSONString






24 changes: 9 additions & 15 deletions python/zingg/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,21 +708,9 @@ def createArgumentsFromJSON(fileName, phase):
:rtype: pointer(Arguments)
"""
obj = Arguments()
obj.args = getJVM().zingg.common.client.argumentst.ArgumentServiceImpl().loadArguments(fileName)
obj.args = getJVM().zingg.common.client.arguments.ArgumentServiceImpl().loadArguments(fileName)
return obj

def writeArgumentsToJSONString(self):
"""Method to create an object of this class from the JSON file and phase parameter value.

:param fileName: The CONF parameter value of ClientOption object
:type fileName: String
:param phase: The PHASE parameter value of ClientOption object
:type phase: String
:return: The pointer containing address of the this class object
:rtype: pointer(Arguments)
"""
jsonString = getJVM().java.lang.String()
return getJVM().zingg.common.client.arguments.ArgumentServiceImpl().writeArguments(jsonString, self.args)

@staticmethod
def createArgumentsFromJSONString(jsonArgs, phase):
Expand All @@ -731,8 +719,14 @@ def createArgumentsFromJSONString(jsonArgs, phase):
return obj

def copyArgs(self, phase):
argsString = self.writeArgumentsToJSONString()
return self.createArgumentsFromJSONString(argsString, phase)
import tempfile
import os
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
temp_file = f.name
self.writeArgumentsToJSON(temp_file)
copied = self.createArgumentsFromJSON(temp_file, phase)
os.unlink(temp_file)
return copied


class ClientOptions:
Expand Down
16 changes: 2 additions & 14 deletions test/testFebrl/testArgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,19 +492,6 @@ def test_writeArgumentsToJSON(self):
self.assertTrue(os.path.exists(json_file_name))
os.remove(json_file_name)

def test_writeArgumentsToJSONString(self):
# print("new args: ", args1)
# print("old args: ", args)
json_string = args1.writeArgumentsToJSONString()
# json_string1 = args.writeArgumentsToJSONString()
print("json_string: ",json_string)
# print("oldjson_string: ", json_string1)
data = json.loads(json_string)
print("data: ", data)

self.assertEqual(data['modelId'], "100")
self.assertEqual(data['zinggDir'], "models")

def test_createArgumentsFromJSONString(self):
sample_json = '''
{
Expand Down Expand Up @@ -808,4 +795,5 @@ def test_set_db_table(self):
pipe = SnowflakePipe("snowflake_pipe")
db_table = "my_table"
pipe.setDbTable(db_table)
self.assertEqual(pipe.pipe.getProps()["dbtable"], db_table)
self.assertEqual(pipe.pipe.getProps()["dbtable"], db_table)

Loading