emissary | open source Kubernetes-native API gateway | REST library
kandi X-RAY | emissary Summary
Support
Quality
Security
License
Reuse
- Setup k8s .
- Return a dict of kubernetes features .
- Dump a config directory .
- Load an IR configuration .
- Generate mapper mapper .
- Update envoy stats .
- Return the base http config .
- Load YAML from a YAML stream .
- Resolve the TLS context .
- Create a configmap plugin .
emissary Key Features
emissary Examples and Code Snippets
Usage of emissary: -alsologtostderr log to standard error as well as files -bind string bind address (default "localhost:1080") -buffersize int buffer size for first read (default 4096) -log_backtrace_at value when logging hits line file:N, emit a stack trace (default :0) -log_dir string If non-empty, write log files in this directory -logtostderr log to standard error instead of files -stderrthreshold value logs at or above this threshold go to stderr -upstream value list of upstream rules (default []) -v value log level for V logs -version show version -vmodule value comma-separated list of pattern=N settings for file-filtered logging
{ "backends": [ {"type": "type_name", "params": {...}}, {"type": "type_name", "params": {...}}, ... ] }
Trending Discussions on emissary
Trending Discussions on emissary
QUESTION
I have a html chart that will display my array from a javascript function 'window.testDataArray'. I would like to replace the sample array with the array data from the server endpoint. I am not sure what I need to do to achieve this.
Client Side
window.testDataArray = function(){
return [6.5,5.2,3.4,5.8] //sample array
};
Updated Client Side(Not Working) I am not sure the syntax is correct here. Any help is very welcome. I am very new to javascript and node.js.
window.testDataArray = async function(){
// return [1,2,3,4,5,6,7,8,9,9,8,7,4,5,6,1,2,3]
try{
return await fetch('http://localhost:3000/array').then(function (data) {
return data
}).catch(function(error){return 'testDataArray' + (error)
});
}
catch(error){'Error testDataArray' + error}
};
Server Side
const express = require('express');
const app = express();
app.get('/array', (req, res) => {
test()
async function test (){
res.send(await local_db.get_data('heights'));//returns array e.g.[5.1,4.3,2.1,5.8]
}
//await local_db.disconnect();
})
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on port ${port}...`));
//console.log("Server running at http://127.0.0.1:3000/ or http://localhost:3000/");
'window.testDataArray' is in utlis.js & is called from 'Line Chart.html'. window.testDataArray fails to get the array from the node.js server endpoint http://localhost:3000/array
Response to Answers Below (Unable to reproduce answer locally what am I missing?)
Thanks for the explanation Emissary your code works like a charm but I cannot get it to work with a local server. I do not intent to have this uploaded to the web. The browser response to the runkit endpoint is 'Cannot GET /'
. But when I navigate to 'http://localhost:3000/array'
I get [0,10,5,2,20,30,45]
. Please see your code below. I have substituted your runkit endpoint for the local one.
Line Chart
Please find server side code below. I have substituted '@runkit/runkit/express-endpoint/1.0.0' for 'express'. I must be missing something fundamental here? Thanks again for the help so far.
const express = require("express")
const cors = require('cors')
const app = express()
app.use(cors())
app.get("/array", (req, res) => {
const data = [0, 10, 5, 2, 20, 30, 45]
res.send(JSON.stringify(data))
res.end();
})
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on port ${port}...`));
``
ANSWER
Answered 2019-Oct-19 at 19:38There are a few issues with your project, I've replicated your server on RunKit - please take note of two important components to this:
- composite object types cannot be returned without serialising them on the server side and deserialising them in the client - HTTP data is transmitted as plain text - this is commonly done via
JSON
. - it isn't clear where you are serving the
.html
file from but looks likely that you'll be running into cross-origin errors - I included middleware to handle this, further reading into CORS available here.
To address the problem described in the question, you are currently trying to statically apply the data to the configuration before a request has responded. Instead try reacting to the data in the promise returned by fetch
.
Forgetting async
/ await
for now, this can be achieved by passing a callback function to .then
- similar to how you are already responding to button click-events elsewhere in your attached example.
const chart = new Chart(
document.getElementById('myChart').getContext('2d'),
{
type: 'line',
// ...
}
)
const API_HOST = 'https://so-58465005-mqksg0z5tsf8.runkit.sh'
fetch(`${API_HOST}/array`)
.then(response => response.json())
.then(data => {
chart.config.data.labels = Array.from(Array(data.length)).map((_, i) => i + 1)
chart.config.data.datasets.push({ label: 'my data', data })
chart.update()
})
QUESTION
Apologies for the malformed title, I can't really think of a better way to describe what I mean to say. Here is my current code:
fromEn = true; // some boolean value
options = {
from: fromEn ? "en" : "es",
to: fromEn ? "es" : "en"
};
I want from
to be "en"
when fromEn
is true and "es"
when it's false. to
should be the "opposite value" of from
, so-to-speak. I feel my current code is too redundant, and although it works I'd like a more elegant solution. Is there a better way of achieving what I'm trying to do?
EDIT: I decided that ternaries are the best way to go. See Emissary's solution for what I've chosen to do, and see my answer lower to find three possible solutions. Thank you all for the help!
ANSWER
Answered 2019-Jul-21 at 20:36Please declare variables with either const
or let
so that those variable don't pollute the scope.
The answer to your question, toggle the fromEn
.
const fromEn = true; // some boolean value
const options = {
from: fromEn ? "en" : "es",
to: !fromEn ? "en" : "es"
};
Hope this helps.
QUESTION
I am working with pandas / python /numpy / datalab/bigQuery to generate an input table for machine learning processing. The data is genomic - and right now, I am working with small subset of 174 rows 12430 columns
The column names are extracted from bigQuery (df_pik3ca_features = bq.Query(std_sql_features).to_dataframe(dialect='standard',use_cache=True))
at the same way, the row names are extracted: samples_rows = bq.Query('SELECT sample_id FROM
speedy-emissary-167213.pgp_orielresearch.pgp_PIK3CA_all_features_values_step_3GROUP BY sample_id')
what would be the easiest way to create a dataframe / matrix with named rows and columns that were extracted.
I explored the dataframes in pandas and could not find the way to pass the names as parameter.
for empty array, I was able to find the following (numpy) with no names:
a = np.full([num_of_rows, num_of_columns], np.nan)
a.columns
I know R very well (if there is no other way - I hope that I can use it with datalab)
any idea?
Many thanks!
ANSWER
Answered 2017-Jun-27 at 22:02If you have your column names and row names stored in lists then you can just use .loc
to select the exact rows and columns you desire. Just make sure that the row names are in the index. You might need to do df.set_index('sample_id')
to put the correct row name in the index.
Assuming the rows and columns are in variables row_names
and col_names
, do this.
df.loc[row_names, col_names]
QUESTION
The following is an issue with genomic data: I use the following query on the pgp data in big query: http://googlegenomics.readthedocs.io/en/latest/use_cases/discover_public_data/pgp_public_data.html (used one sample id for simplicity: hu089792)
*SELECT
sample_id,
allele1Gene,
NTH(2,SPLIT(s.allele1XRef,':')) AS rsID,
NTH(1,SPLIT(allele1Gene,';')) AS input,
NTH(3,SPLIT((NTH(1,SPLIT(allele1Gene,';'))),':')) AS gene1,
NTH(2,SPLIT(allele1Gene,';')) AS input2,
NTH(3,SPLIT((NTH(2,SPLIT(allele1Gene,';'))),':')) AS gene2
FROM
[speedy-emissary-167213:pgp_orielresearch.pgp_variants_gene_dbsnp_hu089792] AS s
LIMIT
10*
**the result is as expected:**
*Row| sample_id| allele1Gene| rsID| input| gene1| input2| gene2
--------------------
1 hu089792 10645:NM_006549.3:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_153499.2:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_153500.1:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_172214.2:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_172215.2:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_172216.1:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_172226.2:CAMKK2:INTRON:UNKNOWN-INC rs3794207 10645:NM_006549.3:CAMKK2:INTRON:UNKNOWN-INC CAMKK2 10645:NM_153499.2:CAMKK2:INTRON:UNKNOWN-INC CAMKK2
2 hu089792 387357:NM_001010923.2:THEMIS:INTRON:UNKNOWN-INC;387357:NM_001164685.1:THEMIS:INTRON:UNKNOWN-INC;387357:NM_001164687.1:THEMIS:INTRON:UNKNOWN-INC rs683202 387357:NM_001010923.2:THEMIS:INTRON:UNKNOWN-INC THEMIS 387357:NM_001164685.1:THEMIS:INTRON:UNKNOWN-INC THEMIS
3 hu089792 10207:NM_176877.2:INADL:INTRON:UNKNOWN-INC rs2666491 10207:NM_176877.2:INADL:INTRON:UNKNOWN-INC INADL null null*
**when i change the limit to 100 / or add another gene extraction, i get null results:**
**the limit change query is:**
SELECT
sample_id,
allele1Gene,
NTH(2,SPLIT(s.allele1XRef,':')) AS rsID,
NTH(1,SPLIT(allele1Gene,';')) AS input,
NTH(3,SPLIT((NTH(1,SPLIT(allele1Gene,';'))),':')) AS gene1,
NTH(2,SPLIT(allele1Gene,';')) AS input2,
NTH(3,SPLIT((NTH(2,SPLIT(allele1Gene,';'))),':')) AS gene2
FROM
[speedy-emissary-167213:pgp_orielresearch.pgp_variants_gene_dbsnp_hu089792] AS s
LIMIT
1000
**The result is:**
*Row| sample_id| allele1Gene| rsID| input| gene1| input2| gene2
------------------
1 hu089792 null rs6078843 null null null null
2 hu089792 null rs79092469 null null null null
3 hu089792 null rs56216546 null null null null
4 hu089792 null rs9576011 null null null null*
**The other query (adding extraction query):**
SELECT
sample_id,
allele1Gene,
NTH(2,SPLIT(s.allele1XRef,':')) AS rsID,
NTH(1,SPLIT(allele1Gene,';')) AS input,
NTH(3,SPLIT((NTH(1,SPLIT(allele1Gene,';'))),':')) AS gene1,
NTH(2,SPLIT(allele1Gene,';')) AS input2,
NTH(3,SPLIT((NTH(2,SPLIT(allele1Gene,';'))),':')) AS gene2,
NTH(3,SPLIT(allele1Gene,';')) AS input3,
NTH(3,SPLIT((NTH(3,SPLIT(allele1Gene,';'))),':')) AS gene3
FROM
[speedy-emissa167213:pgp_orielresearch.pgp_variants_gene_dbsnp_hu089792] AS s
LIMIT 10
**returns:**
*Row| sample_id| allele1Gene| rsID| input| gene1| input2| gene2| input3| gene3
-----------------------
1 hu089792 null rs6551009 null null null null null null
2 hu089792 null rs2050586 null null null null null null
3 hu089792 null rs7151797 null null null null null null*
**any idea why?**
Any help is greatly appreciated
Best,
eilalan
**the original table includes 3 columns that are extracted from [google.com:biggene:pgp.cgi_variants]
see below:**
Row| sample_id| allele1XRef| allele1Gene|
-------------
1 hu089792 dbsnp.107:rs3794207 10645:NM_006549.3:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_153499.2:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_153500.1:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_172214.2:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_172215.2:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_172216.1:CAMKK2:INTRON:UNKNOWN-INC;10645:NM_172226.2:CAMKK2:INTRON:UNKNOWN-INC
2 hu089792 dbsnp.83:rs683202 387357:NM_001010923.2:THEMIS:INTRON:UNKNOWN-INC;387357:NM_001164685.1:THEMIS:INTRON:UNKNOWN-INC;387357:NM_001164687.1:THEMIS:INTRON:UNKNOWN-INC
3 hu089792 dbsnp.100:rs2666491 10207:NM_176877.2:INADL:INTRON:UNKNOWN-INC
ANSWER
Answered 2017-Jun-07 at 15:46BigQuery does not guarantee order of output rows (unless you add explicit ORDER BY)
So, when you change LIMIT - you most likely getting different rows in owtput and for those rows respective extractions produce NULL
To test - I would recommend adding specific ORDER BY so you will have consistent rows output thus you will compare oranges with oranges - not with apples
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install emissary
You can use emissary like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page