I have two test cases, one returns a value, the next is supposed to use the return value.
class GenerateAckFeedTest extends PHPUnit_Framework_TestCase
{
public function testThankyouAckFeedErrors()
{
$ackFeed = array(1,2,3);
return $ackFeed;
}
/***
* #depends testCitiThankyouAckFeedErrors
*/
public function testCitiThankyouAckFeedGeneration(array $ackFeed)
{
}
}
The error I get is:
There was 1 error:
1) testCitiThankyouAckFeedGeneration(GenerateAckFeedTest)
Exception:
ERRNO: 4096
TEXT: Argument 1 passed to GenerateAckFeedTest::testCitiThankyouAckFeedGeneration() must be an array, none given
LOCATION: /home/pvarney/host-server/www/active/unit_tests/GenerateAckFeedTest.php, line 131, at November 15, 2010, 10:55 am
Showing backtrace:
GenerateAckFeedTest.testCitiThankyouAckFeedGeneration() # line 0, file: unknown
ReflectionMethod.invoke(Object:GenerateAckFeedTest) # line 489, file: /usr/share/php/PHPUnit/Framework/TestCase.php
PHPUnit_Framework_TestCase.runTest() # line 404, file: /usr/share/php/PHPUnit/Framework/TestCase.php
PHPUnit_Framework_TestCase.runBare() # line 607, file: /usr/share/php/PHPUnit/Framework/TestResult.php
PHPUnit_Framework_TestResult.run(Object:GenerateAckFeedTest) # line 375, file: /usr/share/php/PHPUnit/Framework/TestCase.php
PHPUnit_Framework_TestCase.run(Object:PHPUnit_Framework_TestResult) # line 677, file: /usr/share/php/PHPUnit/Framework/TestSuite.php
PHPUnit_Framework_TestSuite.runTest(Object:GenerateAckFeedTest, Object:PHPUnit_Framework_TestResult) # line 658, file: /usr/share/php/PHPUnit/Framework/TestSuite.php
PHPUnit_Framework_TestSuite.run(Object:PHPUnit_Framework_TestResult, false, Array[0], Array[0]) # line 324, file: /usr/share/php/PHPUnit/TextUI/TestRunner.php
PHPUnit_TextUI_TestRunner.doRun(Object:PHPUnit_Framework_TestSuite, Array[4]) # line 128, file: /usr/share/php/PHPUnit/TextUI/Command.php
PHPUnit_TextUI_Command.main() # line 52, file: /usr/bin/phpunit
I feel like I'm missing something fairly obvious.
There were two issues, one I believe was the version (I would have accepted Anti's answer, but it was a comment), the other was the number of stars I was using in the comment.
I had
/***
*
*/
I needed
/**
*
*/
According to PHPUnit/Util/Test.php getDependencies() method signature test dependencies were implemented in PHPUnit 3.4.0.
You were using 3.3.16 - an older version which does not support this.
Related
Currently, I am facing with dagster.core.errors.PartitionExecutionError but error logs from Dagster seem not obvious to me.
dagster.core.errors.PartitionExecutionError: Error occurred during the evaluation of the `run_config_for_partition` function for partition set download_firebase_data_local_partition_set
File "/Users/bryan/miniconda3/envs/dagster-injector/lib/python3.9/site-packages/dagster/grpc/impl.py", line 292, in get_partition_config
return ExternalPartitionConfigData(name=partition.name, run_config=run_config)
File "/Users/bryan/miniconda3/envs/dagster-injector/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/Users/bryan/miniconda3/envs/dagster-injector/lib/python3.9/site-packages/dagster/core/errors.py", line 192, in user_code_error_boundary
raise error_cls(
The above exception was caused by the following exception:
TypeError: daily_download_config() takes 1 positional argument but 2 were given
File "/Users/bryan/miniconda3/envs/dagster-injector/lib/python3.9/site-packages/dagster/core/errors.py", line 185, in user_code_error_boundary
yield
File "/Users/bryan/miniconda3/envs/dagster-injector/lib/python3.9/site-packages/dagster/grpc/impl.py", line 291, in get_partition_config
run_config = partition_set_def.run_config_for_partition(partition)
File "/Users/bryan/miniconda3/envs/dagster-injector/lib/python3.9/site-packages/dagster/core/definitions/partition.py", line 441, in run_config_for_partition
return copy.deepcopy(self._user_defined_run_config_fn_for_partition(partition))
File "/Users/bryan/miniconda3/envs/dagster-injector/lib/python3.9/site-packages/dagster/core/definitions/time_window_partitions.py", line 192, in <lambda>
run_config_for_partition_fn=lambda partition: fn(
My current setup is
#graph
def download():
"""
Download data from BigQuery then upload to S3
"""
extract_data_in_date()
#daily_partitioned_config(start_date=datetime(2021, 12, 1))
def daily_download_config(date: datetime):
return {
"resources": {
"date": date.strftime("%Y-%m-%d")
}
}
download_local_job = download.to_job(
name=f'{NAME}_local',
resource_defs={
**{
"date": make_values_resource(date=str),
"project_name": ResourceDefinition.hardcoded_resource("test-123")
},
**RESOURCES_LOCAL,
},
config=daily_download_config,
executor_def=in_process_executor
)
I am not sure where I am wrong, can you please help
#daily_paritioned_config needs to be able to accept two arguments, one for the start of the time window and one for the end. daily_download_config doesn't actually make use of this end date value, but it still needs to show up in the signature because Dagster will try to pass two arguments to this function regardless
I have trained and saved some NER models using
torch.save(model)
I need to load these model files (extension .pt) for evaluation using
torch.load('PATH_TO_MODEL.pt')
And I get the following error: 'BertConfig' object has no attribute 'return_dict'
For the same, I updated my transformer package to the latest one, but the error persists.
This is the stack trace:
Traceback (most recent call last):
File "/home/systematicReviews/train_mtl_3.py", line 523, in <module>
test_loss, test_cr, test_cr_fine = evaluate_i(test_model, optimizer, scheduler, validation_dataloader, args, device)
File "/home/systematicReviews/train_mtl_3.py", line 180, in evaluate_i
e_loss_coarse, e_output, e_labels, e_loss_fine, e_f_output, e_f_labels, mask, e_cumulative_loss = defModel(args, e_input_ids, attention_mask=e_input_mask, P_labels=e_labels, P_f_labels=e_f_labels)
File "/home/anaconda3/envs/systreviewclassifi/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "/home/anaconda3/envs/systreviewclassifi/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 150, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/anaconda3/envs/systreviewclassifi/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "/home/systematicReviews/models/mtl/model.py", line 122, in forward
attention_mask = attention_mask
File "/home/anaconda3/envs/systreviewclassifi/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "/home/anaconda3/envs/systreviewclassifi/lib/python3.6/site-packages/transformers/modeling_bert.py", line 784, in forward
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
File "/home/anaconda3/envs/systreviewclassifi/lib/python3.6/site-packages/transformers/configuration_utils.py", line 219, in use_return_dict
return self.return_dict and not self.torchscript
AttributeError: 'BertConfig' object has no attribute 'return_dict'
Here is some more information about my system:
- `transformers` version: 3.1.0
- Platform: Linux-4.4.0-186-generic-x86_64-with-debian-stretch-sid
- Python version: 3.6.9
- PyTorch version (GPU?): 1.3.1 (True)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No
It worked pretty fine until now, but suddenly this bug appears. Any help or hint is appreciated.
Try to save your model with model.save_pretrained(output_dir). Then you can load your model with model = *.from_pretrained(output_dir) where * is the model class (e.g. BertForTokenClassification).
To save model dictionary rather than an entire model is slightly different. Instead of torch.save(model) use torch.save('path_to_the_model/model.pth') and load using torch.load('path_to_the_model/model.pth').
I have a function in the code that is being called twice.
get_user_settings
once it is getting called in the function I am testing and second time some different module has a function that calls it again.
I have mocked it using pymox like this:
mox = mox.Mox()
mox.StubOutWithMock(utils, "get_user_settings")
utils.get_user_settings("config").AndReturn(mocked_data)
the mocking works for the first call from my test code but when it gets called again in the utils module I get the below error
======================================================================
FAIL: test_uncommited_changes (test_scmCommandBase.TestSCMCommandBase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/local/ciasto/git/myproject/tests/test_scmCommandBase.py", line
79, in test_uncommited_changes
branch.rebase()
File "/local/ciasto/git/myproject/bin/local/cmds/update/core.py",
line 81, in rebase
_utils.save_branch_signature_to_config(user_branch)
File "/local/ciasto/git/myproject/bin/local/config/utils.py", line
146, in save_branch_signature_to_config
content = get_user_settings(project_config)
File "/sw/thirdparty/pymox/0.7.6-bfx1/lib/mox.py", line 886, in __call__
return mock_method(*params, **named_params)
File "/sw/thirdparty/pymox/0.7.6-bfx1/lib/mox.py", line 1193, in __call__
expected_method = self._VerifyMethodCall()
File "/sw/thirdparty/pymox/0.7.6-bfx1/lib/mox.py", line 1246, in
_VerifyMethodCall
expected = self._PopNextMethod()
File "/sw/thirdparty/pymox/0.7.6-bfx1/lib/mox.py", line 1232, in
_PopNextMethod
raise exception
UnexpectedMethodCallError: Unexpected method call
function.__call__('/tmp/tmpbNI_L4/.myproject') -> None
I've already seen this answer:
Gremlin, How to add edge to existing vertex in gremlin-python
and it wasn't really helpful. As suggested in one of the comments I did try to update gremlinpython 3.3.0 but then I get key error.
Stack:
JanusGraph 0.2.0, gremlinpython3.2.3
This is my code
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
martha = g.V().has('name','martha').next()
jack = g.V().has('name','jack').next()
#e_id = g.addE(jack,'likes',martha).next()
e_id = g.V(martha).as_('to').V(jack).addE("Likes").to('to').toList()
print e_id.toList()
StackTrace with gremlinpython 3.3.0
Traceback (most recent call last):
File "gremlin-py.py", line 9, in <module>
martha = g.V().has('name','martha').next()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 70,in next
return self.__next__()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 43,in __next__
self.traversal_strategies.apply_strategies(self)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 352, in apply_strategies
traversal_strategy.apply(traversal)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/remote_connection.py", line 143, in apply
remote_traversal = self.remote_connection.submit(traversal.bytecode)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 54, in submit
results = result_set.all().result()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 429, in result
return self.__get_result()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 381, in __get_result
raise exception_type, self._exception, self._traceback
KeyError: None
In my case, 3.3.0 is throwing error for all queries including g.V().next(). Now going back to 3.2.3, addvertex and other queries are working absolutely fine, but I couldn't figure out how to add edges. The same code when run with 3.2.3 produces,
StackTrace with gremlinpython 3.2.3
Traceback (most recent call last): File "gremlin-py.py", line 12, in <module>
e_id = g.V(martha).as_('to').V(jack).addE("Likes").to('to').toList()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 52, in toList return list(iter(self))
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 70, in next
return self.__next__() File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 43, in __next__
self.traversal_strategies.apply_strategies(self) File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 284, in apply_strategies
traversal_strategy.apply(traversal)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/remote_connection.py", line 95, in apply remote_traversal = self.remote_connection.submit(traversal.bytecode) File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 53, in submit traversers = self._loop.run_sync(lambda: self.submit_traversal_bytecode(request_id, bytecode))
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/tornado/ioloop.py", line 457, in run_sync
return future_cell[0].result() File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/tornado/concurrent.py", line 237, in result
raise_exc_info(self._exc_info)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/tornado/gen.py", line 285, in wrapper
yielded = next(result)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 69, in submit_traversal_bytecode
"gremlin": self._graphson_writer.writeObject(bytecode),
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/structure/io/graphson.py", line 72, in writeObject
return json.dumps(self.toDict(objectData), separators=(',', ':'))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 250, in dumps
sort_keys=sort_keys, **kw).encode(obj)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: v[4184] is not JSON serializable
It says v[x] is not JSON serializable. I'm not sure what causes this error. It'll be awesome if someone can help. If any more info is needed, I shall update the question accordingly.
JanusGraph 0.2.0 uses Apache TinkerPop 3.2.6. You should use the 3.2.6 version of the gremlinpython driver.
pip uninstall gremlinpython
pip install gremlinpython==3.2.6
I'm using the following code in my server program:
class AddLibSong:
def PUT(self):
db = MahData.getDBConnection()
songs = json.loads(web.input().to_add)
addToLibrary(songs)
return
But for some reason when I do a PUT with the data:
"to_add=[ { "album" : "Unknonwn", "artist" : "Unknonwn", "host_lib_id" : "1", "is_deleted" :
"false", "server_lib_id" : "-1", "song" : "Moneytalks" } ]"
I get the following error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/web/application.py", line 237, in process
return self.handle()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/web/application.py", line 228, in handle
return self._delegate(fn, self.fvars, args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/web/application.py", line 409, in _delegate
return handle_class(cls)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/web/application.py", line 385, in handle_class
return tocall(*args)
File "/Users/kurtis/sandbox/udj/webserver/Library.py", line 114, in PUT
song = json.loads(web.input().to_add)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/web/utils.py", line 76, in __getattr__
raise AttributeError, k
AttributeError: 'to_add'
127.0.0.1:51096 - - [29/Sep/2011 19:02:58] "HTTP/1.1 PUT /add_songs_to_library" - 500 Internal Server Error
Anybody know why this is? I think I saw something about Web.py begin only able to get input if given a POST or GET but I didn't see anything in the source code that should prevent this.
Anyway, if you want more details on how to use PUT with WebPy I would advice you this great link.
To make it work on the last version of webpy you should change the "main" code to that:
if __name__ == "__main__":
app=web.application(urls, globals())
app.run()