I'm trying out the Parse SDK in an existing Mac OS X application. I followed the setup steps in the Parse Quickstart guide, including adding an import for the Parse library to my AppDelegate .m file and calling:
[Parse setApplicationId:kParseApplicationID clientKey:kParseClientKey];
in the applicationDidFinishLaunching method. The two constants I use are defined in a Constants file which is also imported.
Towards the end the guide says: "Then copy and paste this code into your app, for example in the viewDidLoad method (or inside another method that gets called when you run your app)"
So I imported the Parse header file into my main view controller .m file and copied and pasted their code into its viewDidLoad method:
PFObject *testObject = [PFObject objectWithClassName:#"TestObject"];
testObject[#"foo"] = #"bar";
[testObject saveInBackground];
When this runs, I hit an exception whose message is "setObjectForKey: key cannot be nil" on that last line. Not on the previous line where I'm actually setting the object for the key. Furthermore, if I stop on the previous line and PO testObject, testObject.allKeys, or testObject[#"foo"], they all show non-nil values for the key "foo". And still furthermore, if I move this code to the end of the AppDelegate's applicationDidFinishLaunching method, the code executes without any errors, and the TestObject shows up in my Parse application dashboard.
Can somebody tell me what I'm doing wrong? I'd really like to explore further, but this is a real blocker for me.
Here's the console log from a slightly more involved OS X app, also occurring on [ParseObject saveInBackgroundWithBlock:]:
2015-06-03 16:55:56.046 TestApp [15795:15954566] An uncaught exception was raised
2015-06-03 16:55:56.046 TestApp [15795:15954566] *** setObjectForKey: key cannot be nil
2015-06-03 16:55:56.046 TestApp [15795:15954566] (
0 CoreFoundation 0x00007fff8fb0103c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff978e476e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8f9e7c66 -[__NSDictionaryM setObject:forKey:] + 1174
3 ParseOSX 0x000000010011adbb __74-[PFMultiProcessFileLockController beginLockedContentAccessForFileAtPath:]_block_invoke + 129
4 libdispatch.dylib 0x000000010026cd43 _dispatch_client_callout + 8
5 libdispatch.dylib 0x000000010026e0b1 _dispatch_barrier_sync_f_invoke + 348
6 ParseOSX 0x000000010011ad15 -[PFMultiProcessFileLockController beginLockedContentAccessForFileAtPath:] + 127
7 ParseOSX 0x00000001000f61ea +[PFObject(Private) _objectFromDataFile:error:] + 207
8 ParseOSX 0x000000010010f231 +[PFUser(Private) _getCurrentUserWithOptions:] + 611
9 ParseOSX 0x00000001000fc4bd -[PFObject(Private) saveAsync:] + 118
10 ParseOSX 0x00000001000e1d25 -[PFTaskQueue enqueue:] + 188
11 ParseOSX 0x00000001000ff06b -[PFObject saveInBackground] + 121
12 ParseOSX 0x00000001000ff270 -[PFObject saveInBackgroundWithBlock:] + 49
13 TestApp 0x0000000100001827 +[SBTParseTranslation saveDBObjectToParse:] + 183
14 TestApp 0x0000000100031fb4 -[SWBMainWindowViewController showRecordForItem:] + 3124
15 TestApp 0x0000000100031268 -[SWBMainWindowViewController showRecordForID:] + 184
16 TestApp 0x0000000100031080 -[SWBMainWindowViewController finishLoad] + 448
17 TestApp 0x0000000100030eb1 -[SWBMainWindowViewController loadData] + 97
18 TestApp 0x0000000100030dd5 -[SWBMainWindowViewController viewDidLoad] + 725
This was caused by a case of confusion on my part. I work mostly on iOS projects, where applicationDidFinishLaunching can typically be counted on to have run before viewControllers load. Apparently that isn't the case in OS X apps.
In short, I was calling the ParseObject save methods before [Parse setApplicationID: clientKey] had been called.
In my case ios7 was crashing with saveInBackground since podfile contained:
platform :ios, '8.0'
and deployment target was 7.0. I replaced with
platform :ios, '7.0'
then clean and build again
Related
I am trying to align 4 difference sequences using MuscleCommandLine. This code works perfectly on Anaconda and Mac but I am trying to make it work on Windows and I am having several issues.
muscle_exe = r'../muscle3.8.31_i86darwin64.exe'
in_file = r'../infile.fasta'
out_file = r'../aln_out.fasta'
muscle_cline = MuscleCommandline(muscle_exe, input=in_file, out=out_file)
muscle_cline()
When I try this using Anaconda on Mac, I get the result. However, when running the same code on Window, I get the following error:
---------------------------------------------------------------------------
ApplicationError Traceback (most recent call last)
<ipython-input-3-70ad09443dc6> in <module>
3 genome = genome_location(before, after, alignment)
4
----> 5 filename = custom_fasta(genome, alignment)
6
7 info = AlignIO.read(r'../aln_out.fasta','fasta')
<ipython-input-1-655071c8d454> in custom_fasta(locations_dict, names)
185
186 muscle_cline = MuscleCommandline(muscle_exe, input=in_file, out=out_file)
--> 187 muscle_cline()
188
189 return(filename)
~\Anaconda3\lib\site-packages\Bio\Application\__init__.py in __call__(self, stdin, stdout, stderr, cwd, env)
567
568 if return_code:
--> 569 raise ApplicationError(return_code, str(self), stdout_str, stderr_str)
570 return stdout_str, stderr_str
571
ApplicationError: Non-zero return code 1 from '../muscle3.8.31_i86darwin64.exe -in ../infile.fasta -out ../aln_out.fasta', message "'..' is not recognized as an internal or external command,"
I have read the documentation but this is not listed as an issue. This same question has been asked before but no solution has been offered. People keep asking to install muscle, but the way it works with Biopython and Anaconda is that you do not need to install it.
So why does this keep happening?
In this Notebook, we use Explainable AI SDK from Google to load a model, right after saving it. This fails with a message that the model is missing.
But note
the info message saying that the model was saved
checking working/model shows that the model is there.
However, working/model/assets is empty.
Why do we get this error message? How can we avoid it?
model_path = "working/model"
model.save(model_path)
builder = SavedModelMetadataBuilder(model_path)
builder.set_numeric_metadata(
"numpy_inputs",
input_baselines=[X_train.median().tolist()], # attributions relative to the median of the target
index_feature_mapping=X_train.columns.tolist(), # the names of each feature
)
builder.save_metadata(model_path)
explainer = explainable_ai_sdk.load_model_from_local_path(
model_path=model_path,
config=configs.SampledShapleyConfig(path_count=20),
)
INFO:tensorflow:Assets written to: working/model/assets
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
/tmp/ipykernel_26061/1928503840.py in <module>
18 explainer = explainable_ai_sdk.load_model_from_local_path(
19 model_path=model_path,
---> 20 config=configs.SampledShapleyConfig(path_count=20),
21 )
22
/opt/conda/lib/python3.7/site-packages/explainable_ai_sdk/model/model_factory.py in load_model_from_local_path(model_path, config)
128 """
129 if _LOCAL_MODEL_KEY not in _MODEL_REGISTRY:
--> 130 raise NotImplementedError('There are no implementations of local model.')
131 return _MODEL_REGISTRY[_LOCAL_MODEL_KEY](model_path, config)
132
NotImplementedError: There are no implementations of local model.
I am trying to work with image files under Scilab, and I get stuck at the very beginning, unable to load an image file.
I have searched the help system as well as the Web, tried two versions of Scilab (because some of the answers I found say that 6.0 is incompatible with some image functions) and still drew a blank. Whatever I try, the imread function is simply not there.
Here is what I get:
Under Scilab 6.0.2:
--> clear
--> atomsSystemUpdate()
Scanning repository http://atoms.scilab.org/6.0 ... Done
--> atomsInstall("SIVP")
atomsInstallList: The package "SIVP" is not registered.
Please check on the ATOMS repository that it is available for Scilab 6.0 on Windows.
If it is, run atomsSystemUpdate() before trying atomsInstall(..) again.
at line 52 of function atomsError ( C:\Program Files\scilab-6.0.2\modules\atoms\macros\atoms_internals\atomsError.sci line 66 )
at line 78 of function atomsInstallList ( C:\Program Files\scilab-6.0.2\modules\atoms\macros\atoms_internals\atomsInstallList.sci line 117 )
at line 233 of function atomsInstall ( C:\Program Files\scilab-6.0.2\modules\atoms\macros\atomsInstall.sci line 249 )
--> atomsInstall("IPCV")
ans =
[]
--> disp( atomsGetInstalled() );
!IPCV 4.1.2 user SCIHOME\atoms\x64\IPCV\4.1.2 I !
--> im=imread("Kratka220.tif")
Undefined variable: imread
Under Scilab 5.5.2:
-->clear
-->atomsSystemUpdate()
Scanning repository http://atoms.scilab.org/5.5 ... Done
-->atomsInstall("SIVP")
ans =
[]
-->atomsInstall("IPCV")
atomsInstallList: Pakiet IPCV nie jest dostępny.
<this is Polish for "Package IPCV is not available"; I installed 5.5.2 in Polish>
!--error 10000
at line 51 of function atomsError called by :
at line 76 of function atomsInstallList called by :
at line 233 of function atomsInstall called by :
atomsInstall("IPCV")
-->disp( atomsGetInstalled() );
column 1 to 4
!SIVP 0.5.3.2 user SCIHOME\atoms\x64\SIVP\0.5.3.2 !
column 5
!I !
-->im=imread("Kratka220.tif")
!--error 4
Niezdefiniowana zmienna: imread
<this is Polish for "undefined variable">
What am I doing wrong?
After atomsInstall you have to restart Scilab to load the toolbox.
I am trying to debug a mono application using WinDbg. The application hangs in an infinite loop inside the C# code that WinDbg is not able to decode internally.
I know I can use the function mono_pmip() to translate a stack address to the name of the function
I'm using .call mono!mono_pmip(0x63a0630) (verified as available using x *!*pmip*), but I still can't get the output of the function, I get an access violation instead.
This is the stack:
34 018feee8 071824eb 0x71824eb
35 018fef08 07181f4c 0x71824eb
36 018fef28 0717fd8a 0x7181f4c
37 018fef68 071708ae 0x717fd8a
38 018fefc8 07170328 0x71708ae
39 018ff078 0716efa5 0x7170328
3a 018ff0e8 0716ed4c 0x716efa5
3b 018ff108 18de8f88 0x716ed4c
3c 018ff1b8 18de75ff 0x18de8f88
3d 018ff208 18de6f6f 0x18de75ff
3e 018ff238 18de660c 0x18de6f6f
3f 018ff2f8 18de60ce 0x18de660c
40 018ff328 18de6033 0x18de60ce
41 018ff348 18ddf586 0x18de6033
42 018ff3e8 18ddebc6 0x18ddf586
43 018ff408 18dde13e 0x18ddebc6
44 018ff418 063a0630 0x18dde13e
45 018ff450 100f1328 0x63a0630
46 018ff480 1005d984 mono!mono_jit_runtime_invoke+0x214 [c:\buildslave\mono\build\mono\mini\mini.c # 4936]
47 018ff4a4 0035e9ce mono!mono_runtime_invoke+0x51 [c:\buildslave\mono\build\mono\metadata\object.c # 2623]
the same function actually works if I use the immediate windows in Visual Studio
(char*)mono.dll!mono_pmip((void*)0x63a0630)
0x15ebf258 " Login.Login:OnClickLoginButton () + 0x4b (21FF75F8 21FF765C) [06E26E70 - Unity Root Domain]"
still I need to make it run in Windbg :(
I wonder if I have to execute the call on the same thread of the call stack I want to debug.
I realised I never answered this question. (char*)mono.dll!mono_pmip((void*)address) is available only on the mainthread, so I had to select the main thread first from the thread list.
I have received the following stacktrace. But I cannot figure out which function from which class has raised this. Can anyone tell me what MainPage..ctor is??
"Frame Image Function Offset
0 coredll.dll xxx_RaiseException 19
1 mscoree3_7.dll 520892
2 mscoree3_7.dll 461967
3 mscoree3_7.dll 534468
4 TransitionStub 0
5 System.InternalTimeZoneInfo.TransitionTimeToDateTime 520
6 System.InternalTimeZoneInfo.GetDaylightTime 100
7 System.InternalTimeZoneInfo.GetIsDaylightSavingsFromUtc 128
8 System.InternalTimeZoneInfo.GetUtcOffsetFromUtc 500
9 System.DateTime.ToLocalTime 164
10 System.DateTime.get_Now 72
11 System.DateTime.get_Today 44
12 xxxx.MainPage..ctor 84
13 mscoree3_7.dll 507848
14 mscoree3_7.dll 184683
15 mscoree3_7.dll 183987
16 mscoree3_7.dll 183375
17 System.Reflection.RuntimeConstructorInfo.InternalInvoke 104
18 System.Reflection.RuntimeConstructorInfo.InternalInvoke 1056
19 System.Activator.InternalCreateInstance 1112"
This is the mainpage constructor:
public MainPage()
{
InitializeButtons();
CreateCalendar();
DisplayHistory();
DisplayStatistics();
}
And inside CreateCalendar I have initialized a variable DateTime currentDate = DateTime.Today; Is this the one creating the trouble?
I suggest to you to move the methods to Page loaded event as follow:
public MainPage()
{
InitializeComponent();
Loaded += MainPage_Loaded; // you may declare it in xaml as well
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
CreateCalendar();
DisplayHistory();
DisplayStatistics();
}
Depending on the kind of operations you are performing inside each method -mainly if it envolves UI -it would be recommended to wrap it into a Dispatcher:
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
CreateCalendar(); //assuming this method does not use UI
Dispatcher.BeginInvoke(() =>
{
//asuming these methods use UI
DisplayHistory();
DisplayStatistics();
});
}
Try it out and let us know,,
cheers
In my case this error occasionaly came out of the blue with some insignificant changes. It failed in initialization stage of tests under running Silverlight Unit Test Framework. Changes were made in project that was indirectly referenced from Unit Test project (i.e. Unit Test project referenced Windows Phone library and the library referenced PCL with changes).
It's redundant to say thay the code I added didn't execute at all when the crash happened!
After commenting out new code with bisection method I ended up that commenting a single line stopped throwing the exception. The line was like this:
var items = jData["items"].Select(token => token.ToObject()).ToList();
where jData is JObject instance from well-known Json.NET. Updating to recent version of Json.NET didn't help.
The error is gone after replacing LINQ expression with explicit ugly for loop (scoffing Resharper says "for loop can be converted to LINQ expression).
So I'm starting to believe in magic.
Hope this helps someone.