Code Monkey home page Code Monkey logo

rpecanapi's People

Contributors

ashiklom avatar dmrathod avatar mdietze avatar robkooper avatar sweetdevil144 avatar tezansahu avatar theakhiljha avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rpecanapi's Issues

New Connect function to accept header requests

Description

Is your feature request related to a problem? Please describe.

Currently we connect to the server without any input headers, which is fine for local development, but once we use runners like Github Actions, we need to specify headers for the host.

Proposed Solution

Describe the solution you'd like
A new connectHost function to accept the Host header

rpecanapi: `ping()` and `get.status()` Functions Return 'Server Not Responding' Error When Connecting to PEcAn Server

Bug Description

When attempting to use the rpecanapi package to connect to the PEcAn server, the functions ping() and get.status() return "Sorry! Server not responding.", which is the default error response in the tryCatch statement.

To Reproduce

Steps to reproduce the behavior:

  1. Load the rpecanapi library.
  2. Connect to the PEcAn server using the connect() function with the appropriate URL, username, and password.
  3. Call the ping() or get.status() function.
  4. See error

Expected behavior

I expect the ping() and get.status() functions to return a response from the PEcAn server indicating its status as follows :

For the ping(server) command :

ping(server)

#> $request
#> [1] "ping"

#> $response
#> [1] "pong"

For the get.status(server) command :

get.status(server)

#> $pecan_details$version
#> [1] "1.7.0"

#> $pecan_details$branch
#> [1] "develop"

#> $pecan_details$gitsha1
#> [1] "unknown"

#> $host_details$hostid
#> [1] 99

#> $host_details$hostname
#> [1] ""

#> $host_details$start
#> [1] 99000000000

#> $host_details$end
#> [1] 99999999999

#> $host_details$sync_url
#> [1] ""

#> $host_details$sync_contact
#> [1] ""

#> $host_details$authentication_required
#> "TRUE"

Screenshots

Screenshot 2024-03-05 at 11 07 34 AM

Machine (please complete the following information):

  • Server : Localhost
  • OS: MacOS

Additional context

I'm running the R session on a Linux machine and attempting to connect to a PEcAn server running locally on port 8000. The server is expected to be responsive as per its normal behavior.

Server URL should be robust to trailing slashes

This should work, whether or not there is a trailing slash:

IP <- "http://localhost:8000/"
server <- connect(IP, username = "carya", password = "illinois")
ping(server)
# Sorry! Server not responding.

However, it currently only works if there is not a trailing slash (i.e., http://localhost:8000).

API POST request gives internal server error

Bug Description

When we bring up the Docker stack in the Docker compose file locally by following the linked documentation and make an API POST request as follows:
The request from the Documentation is as follows:

# Submit a workflow in XML format for execution
xmlFile <- "pecan/tests/api.sipnet.xml"
xml_string <- paste0(xml2::read_xml(xmlFile))
res <- httr::POST(
         "http://pecan.localhost/api/workflows/",
         httr::authenticate("carya", "illinois"),
         httr::content_type("application/xml"),
         body = xml_string
       )
print(jsonlite::fromJSON(rawToChar(res$content)))

We encounter the following error:

$error
[1] "500 - Internal server error"

$message
[1] "Error: $ operator is invalid for atomic vectors\n"

Upon further inspection in the API container in Docker Desktop, we can see the logs as below:

2023-06-27 17:14:54 
2023-06-27 17:14:54 Attaching package: dplyr
2023-06-27 17:14:54 
2023-06-27 17:14:54 The following objects are masked from package:stats:
2023-06-27 17:14:54 
2023-06-27 17:14:54     filter, lag
2023-06-27 17:14:54 
2023-06-27 17:14:54 The following objects are masked from package:base:
2023-06-27 17:14:54 
2023-06-27 17:14:54     intersect, setdiff, setequal, union
2023-06-27 17:14:54 
2023-06-27 17:14:56 Running plumber API at http://0.0.0.0:8000
2023-06-27 17:14:56 Running swagger Docs at http://127.0.0.1:8000/__docs__/
2023-06-27 17:19:23 2023-06-27 11:49:23 DEBUG  [insert.workflow] : 
2023-06-27 17:19:23    INSERT INTO workflows (site_id, model_id, folder, hostname, start_date, 
2023-06-27 17:19:23    end_date, advanced_edit, started_at) VALUES ($1, $2, $3, $4, $5, $6, $7, 
2023-06-27 17:19:23    $8) RETURNING id 
2023-06-27 17:19:24 2023-06-27 11:49:24 DEBUG  [insert.workflow] : 
2023-06-27 17:19:24    Running workflow ID: 99000000087 
2023-06-27 17:19:25 Warning in result_fetch(res@ptr, n = n) :
2023-06-27 17:19:25   Don't need to call dbFetch() for statements, only for queries
2023-06-27 17:19:25 2023-06-27 11:49:25 INFO   [rabbitmq_create_queue] : 
2023-06-27 17:19:25    creating queue pecan in rabbitmq 
2023-06-27 17:19:25 2023-06-27 11:49:25 ERROR  [rabbitmq_send_message] : 
2023-06-27 17:19:25    error sending message to rabbitmq [ 405 ] 
2023-06-27 17:19:25 <simpleError: $ operator is invalid for atomic vectors>

The api.sipnet.xml file is as follows:

<?xml version="1.0"?>
<pecan>
  <pfts>
    <pft>
      <name>temperate.coniferous</name> 
    </pft>
  </pfts>

  <meta.analysis>
    <iter>3000</iter>
    <random.effects>FALSE</random.effects>
    <threshold>1.2</threshold>
    <update>AUTO</update>
  </meta.analysis>

  <ensemble>
    <variable>NPP</variable>
  </ensemble>

  <sensitivity.analysis>
    <quantiles>
      <sigma>-1</sigma>
      <sigma>1</sigma>
    </quantiles>
    <variable>NPP</variable>
  </sensitivity.analysis>

  <model>
    <type>SIPNET</type>
    <revision>r136</revision>
    <id>1000000014</id>
  </model>

  <run>
    <site>
      <id>772</id>
    </site>
    <inputs>
      <met>
        <id>99000000003</id>
      </met>
    </inputs>
    <start.date>2002-01-01 00:00:00</start.date>
    <end.date>2005-12-31 00:00:00</end.date>
    <dbfiles>pecan/dbfiles</dbfiles>
  </run>
</pecan>


Upon further inspection, even if we use the csv file in the Pecan-Status-Board repository, we encounter the same error.

Expected behavior

The workflow should be successfully submitted and tests should be performed against the given data

/assign @robkooper

Error: Problem with `mutate()` column `pfts`.

While running the "run-test-list.R," the following error can be encountered:

Error: Problem with `mutate()` column `pfts`.
ℹ `pfts = strsplit(pfts, "|", fixed = TRUE)`.
x non-character argument

The lead cause of this issue is because of the strsplit function, as it only takes character strings as input.

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.