I am trying to upgrade Elm 0.18 to 0.19 and got stuck on a final step, where I can't figure out how to rewrite Elm 0.18 code to Elm 0.19. One issue I had was that the package mgold/elm-date-format": "1.5.0 <= v < 2.0.0, which was one of the dependencies of the project, was not upgrded yet to support Elm 0.19 so I decided to replace it with ryannhg/date-format. I've also read in the migration docs that Time and Date moved to elm/time but I can't figure out how to rewrite the code below. I have no idea about Elm whatsoever so please go easy on me, I was just tasked to upgrade Elm from 0.18 to 0.19 in my project. I am trying to learn it, though.
Here's the code I have right now which does not work after upgrading to 0.19 plus the full stacktrace. I used the automated Elm upgrade tool for upgrading Elm
Code:
module Views.Note exposing (view)
import Data.Note.Author exposing (Author)
import Data.Note exposing (Note)
import Html exposing (Html, text, span, tr, td, p)
import Html.Attributes exposing (class)
import Date.Format exposing(format)
import Date
import Views.Note.Author
-- VIEW --
view : Note -> List Author -> Html msg
view note authors=
let
author = List.head (List.filter (hasAuthorId note.authorId) authors)
in
case Date.fromString(note.createdAt) of
Ok date ->
tr []
[ td [ class "stacked" ]
[ span [ class "date" ][ text (format "%m/%d/%Y %l:%M %P" date) ]
, Views.Note.Author.view author
, p [ class "text" ][ text note.text ]
]
]
Err _ -> text ""
hasAuthorId : Maybe Int -> Author -> Bool
hasAuthorId authorId author =
case authorId of
Just authorId ->
author.id == authorId
_ ->
False
Stacktrace:
ERROR in ./app/javascript/Page/Notes.elm
Module build failed (from ./node_modules/elm-webpack-loader/index.js):
Error: Compiler process exited with error Compilation failed
-- UNKNOWN IMPORT -------------------------------- app/javascript/Views/Note.elm
The Views.Note module has a bad import:
import Date
I cannot find that module! Is there a typo in the module name?
The "source-directories" field of your elm.json tells me to only look in the
app/javascript directory, but it is not there. Maybe it is in a package that is
not installed yet?
at ChildProcess.<anonymous> (/home/jedrek/workspace/ironin/lease_management_system/node_modules/node-elm-compiler/dist/index.js:131:35)
at ChildProcess.emit (events.js:203:13)
at maybeClose (internal/child_process.js:1021:16)
at Socket.<anonymous> (internal/child_process.js:430:11)
at Socket.emit (events.js:203:13)
at Pipe.<anonymous> (net.js:588:12)
The base type for Dates and Times now is Posix. That's what the formatter functions will expect. The most direct replacement for Date.fromString now is in https://package.elm-lang.org/packages/rtfeldman/elm-iso8601-date-strings/latest/Iso8601 - see the toTime function,
You'll need to handle a result rather than a Maybe, and the total size of your compiled package will go up as this uses parsing libraries rather than using javascript's native data parser
Related
I am trying to run this code using Notepad++ version 8.14
from dearpygui.core import *
from dearpygui.simple import *
#window object setting
set_main_window_size(540, 720)
set_global_font_scale(1.25)
set_theme("Gold")
with window("SMS SMS Spam Filter", width = 520, height = 667):
print("GUI is runngin")
start_dearpygui()
but the output is error which is
from dearpygui.core import *
ModuleNotFoundError: No module named 'dearpygui.core'
I have tried pip install dearpygui on command prompt, but it showed the same. Anyone can solve this?
DearPyGui is under heavy devlopment and the code you are trying to run is the "old" way of doing things (prior to version 0.6). Here is the comparaison between an old and an up-to-date version of the library :
Old version
from dearpygui.core import *
def save_callback(sender, data):
print("Save Clicked")
add_text("Hello, world")
add_button("Save", callback=save_callback)
add_input_text("string", default_value="Quick brown fox")
add_slider_float("float", default_value=0.273, max_value=1)
start_dearpygui()
New version
import dearpygui.dearpygui as dpg
def save_callback():
print("Save Clicked")
with dpg.window(label="Example Window"):
dpg.add_text("Hello, world")
dpg.add_button(label="Save", callback=save_callback)
dpg.add_input_text(label="string", default_value="Quick brown fox")
dpg.add_slider_float(label="float", default_value=0.273, max_value=1)
dpg.start_dearpygui()
See the docs for more details.
I tried the new version but received the segmentation fault message.
I just upgraded from 3.1.17 to 4.1.1 and I'm finding a problem with my shopping lists.
When I get to /customer/shoppinglist/5064 I see this:
Looking at my log files from production I see:
[2020-06-23 17:42:56] request.CRITICAL: Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\UndefinedMethodError: "Attempted to call an undefined method named "getDigitalAsset" of class "Proxies\__CG__\Oro\Bundle\AttachmentBundle\Entity\File"." at /usr/share/nginx/html/oroapp/vendor/oro/platform/src/Oro/Bundle/DigitalAssetBundle/Provider/FileTitleProvider.php line 47 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Attempted to call an undefined method named \"getDigitalAsset\" of class \"Proxies\\__CG__\\Oro\\Bundle\\AttachmentBundle\\Entity\\File\". at /usr/share/nginx/html/oroapp/vendor/oro/platform/src/Oro/Bundle/DigitalAssetBundle/Provider/FileTitleProvider.php:47)"} []
I went to look at the code and I see that in fact there is no method getDigitalAsset in oro/platform/src/Oro/Bundle/DigitalAssetBundle/Provider/FileTitleProvider.php, nor in the proxy... how can this be?
I checked this on my VM (where the problem is not happening) and I see that there's this definition in the proxy class:
/**
* {#inheritDoc}
*/
public function getDigitalAsset()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getDigitalAsset', []);
return parent::getDigitalAsset();
}
But again, I don't see a method called getDigitalAsset in the parent class.
I had some issues when doing the upgrade (I realized my nodejs wasn't upgraded as I thought it was), could that have anything to do with the issue?
Thanks
Edit:
I went through my platform upgrade again and found that there were some problems that prevented it from finishing completely.
This is what I found:
> loading Oro\Bundle\CMSBundle\Migrations\Data\ORM\LoadImageSlider
In LoadImageSlider.php line 117:
Attempted to call an undefined method named "setMainImage" of class "Oro\Bundle\CMSBundle\Entity\ImageSlide".
I commented out the loop inside the load method and re-run the upgrade. Then I got:
> loading Oro\Bundle\CMSBundle\Migrations\Data\ORM\LoadImageSlider
In QueryException.php line 65:
[Semantical Error] line 0, col 117 near 'digitalAsset': Error: Class Oro\Bundle\AttachmentBundle\Entity\File has no association named digitalAsset
In QueryException.php line 43:
SELECT file, digitalAsset, sourceFile FROM Oro\Bundle\AttachmentBundle\Entity\File file INNER JOIN file.digitalAsset digitalAsset INNER JOIN digitalAsset.sourceFile sourceFile WHERE file.parentEntityClass = :parentEntityClass
AND file.parentEntityId = :parentEntityId AND file.parentEntityFieldName =
:parentEntityFieldName
Finally I was able to complete the upgrade by commenting out the whole body of the load method
I had some issues when doing the upgrade (I realized my nodejs wasn't upgraded as I thought it was), could that have anything to do with the issue?
It looks like you have multiple versions of nodejs installed. To make an application use the right one, you can provide the absolute path to the executable with the AssetBundle configuration, like:
# config/config.yml
oro_asset:
nodejs_path: /usr/local/node
npm_path: /usr/local/npm
So I am trying to learn groovy, but I am experiencing some issues with datetime module.
I was looking for answer for 2 hours but I found only one "advice" that haven't helped me.
When I run groovysh in console I get warnings about module that was unable to load:
V 31, 2018 10:10:35 DOP. org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule
newModule
WARNING: Module [groovy-datetime] - Unable to load extension class [org.apache.g
roovy.datetime.extensions.DateTimeExtensions]
V 31, 2018 10:10:35 DOP. org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule
newModule
WARNING: Module [groovy-datetime] - Unable to load extension class [org.apache.g
roovy.datetime.extensions.DateTimeStaticExtensions]
It is groovy 2.5.0, can anybody help me? It also appears with every run of scripts, it's extremely annoying.
I can't get the example code for LinkedIn DataFu's TransposeTupletoBag (at http://linkedin.github.io/datafu/docs/current/datafu/pig/util/TransposeTupleToBag.html) to work.
register datafu-1.1.0.jar
define Transpose datafu.pig.util.Transpose();
x = LOAD 'input.txt' AS (id:int,val1:int,val2:int,val3:int);
dump x
(1,10,11,12)
y = FOREACH x GENERATE id, Transpose(val1 .. val3);
2013-11-08 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070:
Could not resolve datafu.pig.util.Transpose using imports: [, java.lang.,
org.apache.pig.builtin., org.apache.pig.impl.builtin.]
Details at logfile: pig_1383941559971.log
For some reason, Pig cannot find Transpose(). I'm able to use other DataFu functions, so it's not a problem with the JAR path. I'm using Pig 0.11.1 in local mode.
This turned out to be an easy fix. Either DataFu's documentation was mistyped or the API has been updated; Transpose() should be TransposeTupleToBag() (which makes much more sense, anyway). Just replace
define Transpose datafu.pig.util.Transpose();
with
define Transpose datafu.pig.util.TransposeTupleToBag();
and you're good to go.
For example I have a testing code like this:
import Data.Decimal
import Data.Ratio
import Data.Word
import Test.HUnit
import Control.Applicative
import Debug.Trace
import Test.QuickCheck
import qualified Test.QuickCheck.Property as P
import Test.Framework as TF (defaultMain, testGroup, Test)
import Test.Framework.Providers.HUnit
import Test.Framework.Providers.QuickCheck2 (testProperty)
...........
isEQ :: (Eq a, Show a) => a -> a -> P.Result
isEQ a b = if a == b
then P.succeeded
else P.failed {P.reason = show a ++ "\nis not equal to \n" ++ show b}
-- | "read" is the inverse of "show".
--
-- > read (show n) == n
prop_readShow :: Decimal -> P.Result
prop_readShow d = isEQ (read (show d)) d
.............
tests = [
testGroup "QuickCheck Data.Decimal" [
testProperty "readShow" prop_readShow,
testProperty "readShowPrecision" prop_readShowPrecision,
testProperty "fromIntegerZero" prop_fromIntegerZero,
.................
the report of test-framerowk looks like this
dist/build/Main/Main -a2000
QuickCheck Data.Decimal:
readShow: [Failed]
Arguments exhausted after 0 tests
readShowPrecision: [Failed]
Arguments exhausted after 0 tests
fromIntegerZero: [Failed]
without any reason of the fail. The same looking HSpec tests print the fail reason in the report, but test-framework tests does not.
The likely problem here is that QuickCheck is giving up after finding too many unsuitable test cases. Raising topt_maximum_unsuitable_generated_tests will give QuickCheck more opportunities to find acceptable cases and allow the test to finish.
That was a different issue, in fact test-framework-0.8 has a bug https://github.com/batterseapower/test-framework/issues/34 so the high values of tests count (-a parameter) lead to fail.
You just need to reduce the version of test-framework to 0.7.