Giter Club home page Giter Club logo

Comments (7)

Syntaf avatar Syntaf commented on September 17, 2024

I think I can write a hacky workaround for this using the mock library

from dnppy.

Jwely avatar Jwely commented on September 17, 2024

There is a pretty decent thread on mock at stack-overlfow.

In the meantime, I've started to go through and remove a few arcpy dependencies. This has been a long term goal of ours anyways, might as well get started.

from dnppy.

Syntaf avatar Syntaf commented on September 17, 2024

Nice find, if you run into some modules you can't remove the arcpy dependency for you can always commit those modules that cause the error and I can try and fix them.

I'm also working on getting the travis-sphinx to detect sphinx build warnings (like misspelling modules). The problem is the exceptions thrown for stuff like this are already handled by sphinx meaning I can't catch them myself and have no way to detect them. There is a solution out there I just need to find one

build warnings should result in an error not a successful build , so although the docs are technically passing I want to make the requirements for a build to pass much more strict

EDIT: Got it, warnings will now result in errors

from dnppy.

Jwely avatar Jwely commented on September 17, 2024

I usually review the logs at https://travis-ci.org/NASA-DEVELOP/dnppy after a build, but since technically all the issues I've been having are warnings and not errors, it does technically achieve a build passing. It doesn't really hurt anything to finish the build even with warnings, it just means its a good idea to check out the logs from time to time and verify no errors are present.

The download module page works now, there was only one arcpy call and I was able to slide gdal in there pretty easily. This has prompted me to take a better inventory of all the arcpy calls, which I've been meaning to do anyway.

from dnppy.

Jwely avatar Jwely commented on September 17, 2024

I've got it. Running this script:

    def module_mock(module):
        """ attempts to import a module, mocks it upon exception """ 
        try:
            return __import__(module)

        except ImportError:
            print("{0} is being mocked!".format(module))
            import mock
            return mock.MagicMock()

    arcpoops = module_mock("arcpoops")

    output = arcpoops.function("args")
    print(output)

Will produce the following output

>>> arcpoops is being mocked!
>>> <MagicMock name='mock.function()' id='46754480'>

I just need to place a function like this inside the core module, and replace all 27 remaining occurrences of import arcpy with something like

from core import module_mock
arcpy = module_mock("arcpy")

Unless we can think of an even simpler way to do it?

from dnppy.

Syntaf avatar Syntaf commented on September 17, 2024

I believe you can abstract this so it won't actually modify your existing codebase, see this link

from dnppy.

Jwely avatar Jwely commented on September 17, 2024

That was definitely simpler. All module import related issues for travis-ci are now fixed.

from dnppy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.