How to properly import the MetricsServiceV2Client attribute from google.cloud.logging_v2 package? - google-cloud-logging

I am trying to set up a locust based framework for ML load test and need to create custom metrics and logs for which the example that I am following is using 'MetricsServiceV2Client' in 'google.cloud.logging_v2' lib.
In the Vertex Workbench on GCP inspite being on v3.0 of the google-cloud-logging lib I am getting an issue of import
from google.cloud import logging_v2
from google.cloud.logging_v2 import MetricsServiceV2Client
error: cannot import name 'MetricsServiceV2Client' from 'google.cloud.logging_v2' (/opt/conda/lib/python3.7/site-packages/google/cloud/logging_v2/__init__.py)
Interestingly when I test the import in Google's cloud console I am able to import without any issue. What could be the issue?

Change it to the following:
from google.cloud.logging_v2.services.metrics_service_v2 import MetricsServiceV2Client
This will work.

Related

Cannot import package in AWS lambda with Nodejs14.x ES module

I have a layer where the path of node_modules is nodejs/node14/node_modules.
Using that layer, and I try to import a package in a Lambda function, say 'aws-cloudfront-sign', like this:
import cfsign from 'aws-cloudfront-sign'
I got error message
Cannot find package 'aws-cloudfront-sign' imported from /var/task/signer.js\nDid you mean to import aws-cloudfront-sign/lib/cloudfrontUtil.js?
But if I import the package like this:
import cfsign from '/opt/nodejs/node14/node_modules/aws-cloudfront-sign/lib/cloudfrontUtil.js'
It succeeds.
Do you know why? How could I import the package correctly?
This appears to be a bug. It is occurring with layers and the SDK. There are are a number of similar open issues on Github:
Nodejs Lambda: Cannot find package 'aws-sdk'
Cannot find package when using ES Module and Lambda Layer
ES6 imports don't work in #aws-sdk/client-iotsitewise
As you have worked out, the only workaround at present seems to be the use of absolute paths. E.g.:
import { DynamoDB } from 'aws-sdk;'
fails, whereas
import AWS from '/var/runtime/node_modules/aws-sdk/lib/aws.js';
const { DynamoDB } = AWS;
will work.
I suggest you add your voice to an existing open issue to help ensure it gets attention.

Where to import React-Bootstrap components from?

I am using React-Bootstrap version 1.0.0-beta.10.
Whenever I want to use a component, for example Alert, I will get three import options from the IDE to choose from:
"react-bootstrap"
"react-bootstrap/Alert"
"react-bootstrap/es/Alert"
Which of them should I use and why?
Yes. We have multiple options to import a component.
When importing directly from react-bootstrap you need to import as,
import {Alert} from `react-bootstrap`;
Because Alert component is exported as named export.
If you expand the react-bootstrap folder from node_modules folder, you will see multiple folders and files.
The files directly available in react-bootstrap folder are based on ES5.
When I say based on ES5 means, the required package for this component are imported like this,
var _extends2 = _interopRequireDefault(require("#babel/runtime/helpers/extends"));
and you can import component as,
import Alert from `react-bootstrap/Alert`;
Because Alert component is exported as default export.
The files available in es folder are based on ES6.
When I say based on ES6 means, the required package for this component are imported like this,
import _extends from "#babel/runtime/helpers/esm/extends";
and you can import component as,
import Alert from `react-bootstrap/es/Alert`;
Because Alert component is exported as default export.
You must have to change your codebase.
react-bootstrap doesn't have a default export, so the default import syntax cannot be used in this case.
You can do the following though:
import * as ReactBootstrap from 'react-bootstrap';
And then, you can use the Alert component.

Using extentreports for jmeter test results

As anyone who uses jmeter for api functional testing, the reporting is, eh, not that great. Has anyone used something like http://extentreports.com/ for displaying their test results? Any ideas on other ways to display test results better? In trying to use a tool that was mainly focused on performance testing and those test results, that does not work as well for when we are testing REST API calls and those results. For example, it would be nice to be able to capture data that is getting created during the test runs but, none of the reports that are built into jmeter do this. Any advice is appreciated.
Looking into Extent - Report API it should be possible to integrate it with JMeter, see How to Write a plugin for JMeter guide to get started
You can generate an HTML Reporting Dashboard at the end of your test run, it is not that bad.
You can use Backend Listener to store JMeter test results somewhere and visualise them in the most suitable for your form. See Real-time results JMeter User Manual chapter for more details.
And last but not least you can use 3rd-party analysis services like JAnalyzer or BM.Sense
I was able to use extentreports 2.41.1 and posted this code into a JSR223 PreProcessor. This seems to be the wrong element to put this in because I need results for each endpoint to show up in the report. This only just shows the script ran. Anyway, sharing in hopes it helps others
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
ExtentReports report;
ExtentTest testLogger;
String resultsPath = "C:/portalQA/Automation/Results";
String configPath = "C:/jmeter/apache-jmeter-3.2/lib";
String reportPath;
reportPath = resultsPath+"/test2/testing_extRpts_${myTimeinMills}.html";
report = new ExtentReports(reportPath, true);
report.loadConfig( new File(configPath+"extent-config.xml"));
testLogger = report.startTest("Entire Script");
testLogger.log(LogStatus.INFO, "This is the API test script for Login");
report.flush();
//Thread.sleep(2000);
//report.close();

No More Import Button on Parse

I no longer see the import button on Parse to import a JSON or CSV file. Did they move it somewhere or is it no longer possible to import those file types?
the official reason is this:
"[The import class button] was removed a couple of days ago due to an app that was abusing it and affecting people that had not migrated out yet. Now that the database is running on your own infra, you can simply importing directly to mongo so this shouldn’t be blocking you."
I hope this helps (to answer the question, not to import your class of course).
Cheers,

Swift - Import my swift class

This question is asked several times, but I can't find the right solution for my problem. I'm trying to import my Player.swift class in my MainScene.swift (I've used Cocos2D - SpriteBuilder to setup the project; Now using Xcode).
This is my folder structure:
I've tried to use import Player; and import Player.swift;, but when I tried I got this error: No such module 'Player.swift'
How do I import it correctly?
Thanks!
By the way, I'm a beginner in Swift, so don't expect that I know all of the terms
You don't need to explicitly import files in Swift as they are globally available through the project. If you want to access the methods or properties of Player class, you can directly make object of Player class in MainScene.Swift file and can access to it.
e.g var objPlayer = Player()
There is no need to import swift classes to use in other swift classes.
They are available to use automatically.
In Swift you can only import module, e.g. any framework like UIKit, MapKit as below. You cannot import swift classes.
import UIKit
import MapKit
Just make sure its selected to use in target in which your are trying to use.
Check below images for more idea.
In this image my HomeViewController.swift is selected to use in AutolayoutDemo module.
In below image I have unchecked AutolayoutDemo module for the class DetailsViewController.swift.
So now onwards when I will try to use the DetailsViewController compiler will give me error as below image in HomeViewController.
When it comes to Swift imports, there are two cases:
1) The type to import is in the module
In this case, no import statement is needed. As long as the type is not private or fileprivate, you can directly access it.
2) The type to import is outside of the module
You can import an entire module using:
import ModuleName
If you only want to import a specific type or function from the module, you can do this using the following format:
import kindOfThing ModuleName.Type
where kindOfThing is class/struct/func/etc...
A much deeper exploration of this can be found on NSHipster here.
Check if the class is added to your iOS target in right Pane or not .

Resources